Hi there all, so I’m working on a movement and camera rotation system, that successfully rotates, however, when trying to reset it using the GameObject it’s from… nothing happens, could someone help me to resolve this please(script below)
public class DevMovement : MonoBehaviour
{
public CharacterController controller;
public float speed = 12f;//movement speed
public float rise = 1f;//for making the User rise from the floor
public float rotate = 1f;//responsible for rotating camera
public GameObject userBody;
// Update is called once per frame
void Update()
{
float x = Input.GetAxis("Side");
float z = Input.GetAxis("Forward");
float y = Input.GetAxis("UP"); // For moving the user up and down off the floor
float rotateZ = Input.GetAxis("Rotate"); //Rotates object on the z axis
Vector3 move = transform.right * x + transform.forward * z;
controller.Move(move * speed * Time.deltaTime);
transform.Translate(0, rise * y * Time.deltaTime, 0f);//for Rising off the ground & vice-versa
transform.Rotate(0, 0, rotate * rotateZ * Time.deltaTime);//Rotates the camera
// `````````````````````````````````````````````````````````````````````````````````````````````````
//Problem zone
if (Input.GetKeyDown(KeyCode.R))//Button doesn't register the reset action
{
userBody.transform.Rotate(0, 0, 0);//Reset the camera's rotation
}
}
}
I appreciate all the help in advance