problem with directional control and movement
I am attempting to navigate a capsule through 3D space using a trigger button to say if engine is active or not and a joystick for directional control. Code below:
private void Update()
{
if (Input.GetButtonDown("Pulse"))
pulse = 1;
if (Input.GetButtonUp("Pulse"))
pulse = 0;/**/
}
private void FixedUpdate()
{
float moveHorizontal = Input.GetAxis("Vertical");
float moveVertical = Input.GetAxis("Horizontal");
float moveForward = pulse;
//float xOld = rb.transform.eulerAngles.x;
yRotation += (moveHorizontal * rb.velocity.magnitude * rotSpeed /**/);
xRotation += (-moveVertical * rb.velocity.magnitude * rotSpeed/**/);
rb.transform.eulerAngles = new Vector3(90.0f + xRotation, yRotation, 0.0f);
Vector3 movement = rb.transform.up * pulse;
//rb.AddForce(movement * speed);
rb.AddForce(movement.x * speed, movement.y * speed, movement.z * speed, ForceMode.Impulse);
}
The "engine" will not work whilst turning. It will stop if I turn and will not start if I have set the joystick to turn. The problem is the same for all ForceModes. What can I do so that the capsule will move when the "pulse" button is active, regardless of the directional controls?
Comment
Your answer
Follow this Question
Related Questions
Got unwanted motion blur on fast moving object (Only iOS) 0 Answers
Arrow mechanic like soccer star 0 Answers
I don't want the arms to turn with the ball at my game 0 Answers
Rigidbody sticks to wall 0 Answers
How tou use a UI Button to move Player? 0 Answers