So I’m going through the project boost course at the moment and I’m on lesson 37. The AddRelativeForce() method isn’t doing anything but I’m seeing my key input is still being logged to console. I’m not sure how to proceed, should I switch to using Rigidbody.velocity?
Here’s my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movement : MonoBehaviour
{
Rigidbody rb;
[SerializeField] float rocketThrust = 2f;
[SerializeField] float velocityX = 0f;
[SerializeField] float velocityY = 10f;
[SerializeField] float velocityZ = 0f;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody>();
}
// Update is called once per frame
void Update()
{
ProcessThrust();
ProcessRotation();
}
void ProcessThrust()
{
if (Input.GetKey("space"))
{
Debug.Log("Pressed space - thrusters active");
rb.AddRelativeForce(Vector3.up * rocketThrust);
}
}
void ProcessRotation()
{
if (Input.GetKey("a"))
{
Debug.Log("Rotating left");
}
else if (Input.GetKey("d"))
{
Debug.Log("Rotating right");
}
}
}