- Home /
Question by
AtomicLamp · Feb 14 at 03:56 PM ·
mouserotate objectmouselookrotation axis
rotate object on its axis base on x mouse movement
Hi, im making a tank turret that rotate on its axis with the mouse x :
i mean that if i move my mouse on the x axis the turret will spin around on its y axis
do anyone have an idea?
screenshot-9135.png
(177.5 kB)
Comment
are you using the new or the old input system? in general you can just transform.Rotate(Vector3.up * x);
Answer by SellPet · Feb 14 at 07:03 PM
try something like this
float xRotation;
float mouseX = Input.GetAxis("Mouse X");
xRotation += mouseX;
Turret.LocalRotation = Quaternion.Euler(Vector3.up OR transform.up * xRotation * Time.deltaTime);
hope it helps