unity3d给物体增加扭矩力
using UnityEngine;
using System.Collections;
public class AddTorqueExample : MonoBehaviour
{
public float amount = 50f;
void FixedUpdate ()
{
float h = Input.GetAxis("Horizontal") * amount * Time.deltaTime;
float v = Input.GetAxis("Vertical") * amount * Time.deltaTime;
rigidbody.AddTorque(transform.up * h);
rigidbody.AddTorque(transform.right * v);
}
}
- 上一篇:工业设计专业虚拟现实技术教学改革 2019/4/28
- 下一篇:unity3d物体移动的方法 2019/4/9
