Hey all I have a problem on how to addForce in the correct direction. First let me Explain what’s going on in the game:
We are in space…
therefore, to me it would make sense to use Addforce (considering the old law "an object in motion tends to stay in motion(unless interfered with)). //Yes I’m kind of a geek// lol but uh…
The problem here in lies, when the ship flips a 180 the “up Key” still adds force as if we were at 0 on the Y axis.
what could I add to this to help it take the Y axis into account?
Thanks in advance.
void FixedUpdate(){
//This is for ship movement (physics)//
float moveHorizontal = Input.GetAxis (“Horizontal”);
float moveVertical = Input.GetAxis (“Vertical”);
Vector3 movement = new Vector3(moveHorizontal, 0f, moveVertical);
RB = GetComponent ();
RB.AddForce ((speedCurrent * movement * Time.deltaTime) * 10);
Vector3 yPos = new Vector3 (transform.position.x, 0, transform.position.z);
transform.position = yPos;
}
//Please note yPos is a temporary y position holder until I program Y movement.