Hello.
I am working on a game with ships.
I modify the ships speed using addRelativeForce. I am limiting the speed to say 100.
After the ship accelerates to the max speed I change it’s direction (while still traveling in the original direction at max speed), now I need to get the speed it’s traveling at in the new direction (forward) but I keep getting the global speed in the forward direction, and since the ship is already at full speed I can’t accelerate in new direction.
How do I read the ships speed in the local forward direction?
I have added the code below.
if (Input.GetButton("w") && transform.InverseTransformDirection(Ship.rigidbody.velocity).z < 100)
{
if (Input.GetButtonDown('w'))
{
//thruster_audio(1);
}
Ship.rigidbody.AddRelativeForce(Vector3.forward*1000*Time.deltaTime);
if (Thruster1.particleSystem.startSpeed < 20)
{
Thruster1.particleSystem.startSpeed += 10 * Time.deltaTime;
Thruster2.particleSystem.startSpeed += 10 * Time.deltaTime;
Thruster3.particleSystem.startSpeed += 10 * Time.deltaTime;
Thruster4.particleSystem.startSpeed += 10 * Time.deltaTime;
Thruster5.particleSystem.startSpeed += 10 * Time.deltaTime;
}
}