【发布时间】:2019-09-13 18:05:03
【问题描述】:
我正在开发一个需要一些真实物理的太空游戏,例如空间中的轨道和动量守恒,问题是,我无法开发一个代码来识别空间中物体的角加速度并纠正它使用动量力。
这是我编写的用于稳定旋转的函数:
void RCS_Stabilize()
{
Vector3 localangularvelocity = transform.InverseTransformDirection(rigidBody.angularVelocity);
Debug.Log(localangularvelocity);
if (!isRCSinUse)
{
if (localangularvelocity.x < RCSthreshole)
{
RCS_Pitch(1);
}
else if (localangularvelocity.x > -RCSthreshole)
{
RCS_Pitch(-1);
}
// after that i do the same for y and z
这就是 RCS_Pitch 函数:
void RCS_Pitch(int direction)
{
rigidBody.AddRelativeTorque(new Vector3(direction * RCSPower, 0, 0));
if (direction == 1) // Just show the smoke effect
{
RCSeffect[0].startSpeed = 1f;
RCSeffect[3].startSpeed = 1f;
}
else
{
RCSeffect[1].startSpeed = 1f;
RCSeffect[2].startSpeed = 1f;
}
}
这些函数有点工作,但它们基本上每帧都被调用,导致烟雾效果每帧都打开并且有时会闪烁。
【问题讨论】:
-
什么是
RCSeffect?RCSeefect[i].startSpeed是如何使用的? ....这在哪里叫...也许然后..不是每一帧都叫它? -
RCSeffect 只是粒子系统,它不会在身体上添加任何真实的力。
标签: c# unity3d game-physics