Unity 自己lu带有惯性(缓动)的代码
来源:互联网 发布:网络诈骗5000元判缓刑 编辑:程序博客网 时间:2024/05/18 02:13
先看效果:
using System.Collections;
using System.Collections.Generic;using UnityEngine;
public class RotionAround : MonoBehaviour {
float x;
float y;
public float speed = 50f;
public Transform obj; //围绕的点
bool keepMove = false;
public float smoothness = 0.02f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButton(0))
{
x = Input.GetAxis("Mouse X");
y = Input.GetAxis("Mouse Y");
if ((x > -0.2f && x < 0.2f) && (y > -0.2f && y < 0.2f))
{
return;
}
transform.RotateAround(obj.position, Vector3.up, x * speed * Time.deltaTime);
transform.RotateAround(obj.position, transform.right, -y * speed * Time.deltaTime);
StopCoroutine("StopMove");
}
if (Input.GetMouseButtonUp(0))
{
keepMove = true;
}
if (keepMove) //惯性(缓动)
{
if (x > -0.001f || x < 0.001f)
{
StartCoroutine("StopMove");
}
x = x - x * smoothness;
y = y - y * smoothness;
transform.RotateAround(obj.position, Vector3.up, x * speed * Time.deltaTime);
transform.RotateAround(obj.position, transform.right, -y * speed * Time.deltaTime);
}
}
IEnumerator StopMove()
{
yield return new WaitForSeconds(4);
keepMove = false;
}
}
0 0
- Unity 自己lu带有惯性(缓动)的代码
- 自己lu缓动效果2(自转)
- 带有回弹的ScrollView支持左右惯性。
- JS带有惯性的拖拽,摩擦,甩动元素
- Unity的Lerp函数实现缓动
- HTML5手机开发——滚动和惯性缓动
- 矩阵的 LU 分解法(LU decomposition)
- Unity拖动摄像机加上惯性滑动的效果
- 动软.net代码生成器自定义模板(根据自己需要来生成数据访问类)及牛腩的动软的简单使用(原创)
- 有关线性代数的Matlab代码笔记(6)——LU分解(没有行变换)
- LU 分解 (LU Decomposition)
- 矩阵的LU分解(Matlab程序)
- Unity动态创建带有Shader的Material
- 惯性动捕研发之路
- 带有弹动效果的加载动画实现
- Unity中3D一些使用方法代码(为自己)
- 自己进化的Unity人工智能(一)
- 自己进化的Unity人工智能(二)
- Spring MVC接受XML格式的数据
- google.protobuf.message.DecodeError: Truncated message. 解决方法
- linux 环境变量设置
- ARM64 Exception vectors
- linux日常总结
- Unity 自己lu带有惯性(缓动)的代码
- [POJ]
- 剑指offer 32 统计数字出现次数
- android图形
- iOS webView “NSURLErrorDomain”错误 -999
- Onvif协议客户端开发【1.概念篇】
- YII踩坑纪录
- Ubuntu下LAMP环境的搭建以及远程连接MySQL数据库
- svn的常见错误