Rocket takes too long to change direction

Good afternoon,

I have a problem with the rocket controls. Basically, when I rotate and press space, the rocket keeps going on the trajectory and takes too long for changing direction. The problem might be the angular drag but doesn’t matter how high I set it, nothing change.

Video: Here you can see the video

As you can see in the video when I turn the rocket, it takes ages to change direction, and I’ll eventually hit the sidewall.

using UnityEngine;

[RequireComponent(typeof(Rigidbody), typeof(Thrust))]
public class InputsController : MonoBehaviour
{
    private Rigidbody rocketBody;
    private Thrust thrust;

    [Header("Custom Settings")]
    [SerializeField] private float rotationSpeed = 250f;

    void Start()
    {
        rocketBody = GetComponent<Rigidbody>();
        thrust = GetComponent<Thrust>();
    }
    private void FixedUpdate()
    {
        Thrust();
    }

    void Update()
    {
        Rotate();
    }

    private void Thrust()
    {
        if (thrust == null) return;

        if (Input.GetKey(KeyCode.Space))
        {
            rocketBody.AddRelativeForce(Vector3.up * thrust.GetPower());
        }
    }

    private void Rotate()
    {
        rocketBody.freezeRotation = true;

        if (Input.GetKey(KeyCode.A))
        {
            transform.Rotate(Vector3.forward * rotationSpeed * Time.deltaTime);
        }
        else if (Input.GetKey(KeyCode.D))
        {
            transform.Rotate(-Vector3.forward * rotationSpeed * Time.deltaTime);
        }

        rocketBody.freezeRotation = false;
    }
}

increase rigidbody drag value.

Done already. If I set it to 0.5 or to 100 there is no difference.

UP Please I really can’t understand what is wrong.

Hi Ravenje,

To me, the movement of your rocket looks fine. I don’t know what your problem is but you could try to move all the MeshRenderers and their respective Collider component to child game objects of the Rocket parent.

The Rocket parent may not have any Renderers or Colliders attached. The parent may have the Rocket script and the Rigidbody only. Nothing else. It’s scale must be set to (1, 1, 1).

Maybe this way, you’ll achieve the desired result.

Increasing Rigidbody drag helps 100%. Because now his rocket doesnt have movement resistance if drag is 0, and will continue travelling. In my project this works fine.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms