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;
}
}