- Home /
Question by
Gameart1235 · Sep 20, 2015 at 05:57 PM ·
topdowntop down shooter
3D Top Down Rotation (PLZ HELP)
So I'm making a 3D top down Shooting game and it coming out ok but I just can't get the aim to rotation right. Here my code, what am I'm doing wrong.
var mouse : Vector3;
var rot : Quaternion;
function Update ()
{
mouse = Camera.main.ScreenToWorldPoint(Input.mousePosition);
rot = Quaternion.LookRotation(target.position - mouse, Vector3.forward);
transform.LookAt(rot);
}
PLZ HELP
Comment
Answer by Cherno · Sep 20, 2015 at 09:34 PM
mouse = Camera.main.ScreenToWorldPoint(Input.mousePosition);
rot = Quaternion.LookRotation(transform.position - mouse, Vector3.forward);
transform.rotation = rot;
transform.eulerAngles = new Vector3 (0, 0, transform.eulerAngles.z);
//rigidBody2D.angularVelocity = 0; //if needed