-1
在我的乒乓球比赛中,球应该反弹,永远不会变慢。然而,随着时间的推移,球正在稳步放缓。我会把球对象和脚本的图像。 这里是左侧 统一乒乓球游戏球物理减速问题
球属性以下是使用UnityEngine球脚本 ;使用System.Collections的 ;
public class球:MonoBehaviour { public float ballVelocity = 3000;
Rigidbody rb;
bool isPlay;
int randInt;
void Awake()
{
rb = GetComponent<Rigidbody>();
randInt = Random.Range(1,3);
}
void Update()
{
if (Input.GetMouseButton(0) && isPlay == false)
{
transform.parent = null;
isPlay = true;
rb.isKinematic = false;
if (randInt == 1)
{
rb.AddForce(new Vector3(ballVelocity, ballVelocity, 0));
}
if (randInt == 2)
{
rb.AddForce(new Vector3(-ballVelocity, -ballVelocity, 0));
}
}
}
}
我一直被卡住,对团结是新的,所以任何帮助都会很棒!如果您需要更多信息,请发表评论!
whatreü说话回合 – Temo
对不起,我没有看到第二图像中的材料。你还可以尝试的其他事情是将第二个参数添加到“AddForce”方法。尝试使用'ForeMode.Acceleration'(因为我假设你想忽略对象质量),如果你想考虑质量,那么使用'ForeMode.Force'。如果这些工作都不起作用,那么您可以尝试的另一件事是使用'transform.forward'而不是'ballVelocity'。 – Agustin0987