C# 将对象提升到位,并在另一个轴上跟随鼠标
所以我试着让一个刚体提升到一个设定的高度,然后用鼠标在另一个轴上移动C# 将对象提升到位,并在另一个轴上跟随鼠标,c#,unity3d,C#,Unity3d,所以我试着让一个刚体提升到一个设定的高度,然后用鼠标在另一个轴上移动 private void levitateObject() { Ray playerAim = playerCamera.GetComponent<Camera>().ViewportPointToRay(new Vector3(0.5f, 0.5f, 0)); /*Finds the next position for the object held to move to, dependi
private void levitateObject()
{
Ray playerAim = playerCamera.GetComponent<Camera>().ViewportPointToRay(new Vector3(0.5f, 0.5f, 0));
/*Finds the next position for the object held to move to, depending on the Camera's position
,direction, and distance the object is held between you two.*/
Vector3 nextPos = playerCamera.transform.position + playerAim.direction * 5;
//Takes the current position of the object held
Vector3 currPos = levitatingObject.transform.position;
levitatingObject.GetComponent<Rigidbody>().velocity = (nextPos - currPos)*10 ;
}
有什么问题吗?现在我想和5号摄像机保持一定的距离,但我想保持不变。