我无论如何都不是物理学专家,因此我无法确切地告诉我所寻找的效果如何。我只是把它称为“下旋”现在:)Unity3d:带有刚体的球体后旋体
图片这样的场景:
有在一张乒乓球桌的你面前一个乒乓球。你用手指在它上面施加压力(用很大的力量从球的顶部到底部)。乒乓球会从你的手指向前滑动但是向后旋转。所以,尽管它已经向前移动时它最终会退回给你,因为它向后旋转:d
我希望是有道理的。我真的不知道这种效应是如何被调用的,所以我不能真正查找解决方案。
我确实有一个简单的平面上有一个球体(刚体连接)。我想通过在屏幕上滑动来模拟这种确切的效果。但最重要的是,如何实现这一效果?效果也应该通过确切地将压力放在球的位置(左侧或右侧)来实现。我只是希望它在向后旋转时向前移动,并且由于其反向力而最终回滚(不完全相同,但更现实)。
我已经尝试过使用Addforce和Addtorque,但没有成功。
任何帮助,高度赞赏。
祝您有美好的一天!
编辑:我有什么至今:
public float spin = 1000f;
public float force = 20f;
public float angularVelocity = 100f;
private Rigidbody rb;
private Vector3 oldPos;
private Quaternion oldRot;
public int pressed = 0;
void Start() {
oldPos = transform.position;
oldRot = transform.rotation;
rb = GetComponent<Rigidbody>();
rb.maxAngularVelocity = angularVelocity;
}
void FixedUpdate()
{
Debug.Log(rb.velocity.magnitude);
if (Input.GetKey(KeyCode.Space))
{
Debug.Log("pressed");
pressed = 1;
rb.AddForce(new Vector3(0,0,force),ForceMode.VelocityChange);
rb.AddTorque (new Vector3 (-spin, 0, 0), ForceMode.Force);
}
}
EDIT2:
public float spin = 1000f;
public float force = 20f;
public float angularVelocity = 100f;
private Rigidbody rb;
private Vector3 oldPos;
private Quaternion oldRot;
public int pressed = 0;
public float forceTime = 1f;
public float startBack = 0.25f;
void Start() {
oldPos = transform.position;
oldRot = transform.rotation;
rb = GetComponent<Rigidbody>();
rb.maxAngularVelocity = angularVelocity;
}
void FixedUpdate()
{
Debug.Log(rb.velocity.magnitude);
if (pressed == 2)
{
rb.AddForce(new Vector3(0,0,-force),ForceMode.Acceleration);
}
else if (pressed == 1 && rb.velocity.magnitude <= startBack && rb.velocity.magnitude >= 0f)
{
pressed = 2;
StartCoroutine("StopForce");
}
else if (Input.GetKeyDown(KeyCode.Space) && pressed == 0)
{
Debug.Log("pressed");
rb.AddForce(new Vector3(0,0,force),ForceMode.VelocityChange);
rb.AddTorque (new Vector3 (-spin, 0, 0), ForceMode.Force);
pressed = 1;
}
}
IEnumerator StopForce() {
yield return new WaitForSeconds(forceTime);
pressed = 3;
}
添加你能不能负旋转量添加到游戏对象,并使用添加力向前移动。你也可以添加一个物理材质,它会影响它与表面的反应方式。这可能会帮助你 http://answers.unity3d.com/questions/377944/how-to-make-a-ball-rotate-as-per-its-moving-direct.html] –