So I'm creating a top-down shooter and trying to make the player face the direction of the joystick. this is my current code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(PlayerMotor))]
public class PlayerController : MonoBehaviour {
Camera cam;
PlayerMotor motor;
void Start () {
cam = Camera.main;
motor = GetComponent<PlayerMotor>();
}
void Update () {
//movement
motor.MoveToPoint(new Vector3(transform.position.x + Input.GetAxis("Horizontal"), transform.position.y, transform.position.z + Input.GetAxis("Vertical")));
//cam control
cam.transform.position = new Vector3(transform.position.x,
transform.position.y + 9.0f,
transform.position.z);
//this is the problem
transform.Rotate(new Vector3(transform.position.x + Input.GetAxis("rightStickHorizontal"), transform.position.y, transform.position.z + Input.GetAxis("rightStickVertical")));
}
}
for some reason when I do this it just turns ever so slowly in the direction of the joystick (appears to be 1 degree per frame).