Strange rotating Behaviors [solved]

Answer: I had the rocket script on my camera. Man that was silly, and I have no idea how it happened. Only took 24 hours of pondering to figure it out too… lol

I have an interesting affect at the end of this lecture. My ship only rotates when thrusting. If I use A and D when I’m not thrusting, it spins my whole game instead of my ship.

My code appears to be nearly identical at the end of the lecture, but I’m sure there is something small I’ve overlooked. I also played with the local and global settings in unity and that doesn’t seem to be it either. Appreciate any help. Thank you.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Rocket : MonoBehaviour {

Rigidbody rigidBody; //member variable set to access Rigidbody to move ship

// Use this for initialization
void Start ()
{
    rigidBody = GetComponent<Rigidbody>();
}

// Update is called once per frame
void Update ()
{
    ProcessInput();
}

private void ProcessInput()
{
    if (Input.GetKey(KeyCode.Space)) //can thrust while turning
    {
        rigidBody.AddRelativeForce(Vector3.up);
    }

    if (Input.GetKey(KeyCode.A))
    {
        transform.Rotate(Vector3.forward); // rotates ship
    }
    else if (Input.GetKey(KeyCode.D))
    {
        transform.Rotate(-Vector3.forward);
    }
}

}

Privacy & Terms