Hey everyone, so I’ve been wanting to know how to get my character to control like they do in guild wars, looking at the mouse but only rotating on the y axis. I have him looking at the mouse but he’s not locked to any axis (you can imagine the problem there) I’m guessing I use Eulerangle’s correct? I haven’t used these much and when I did it didn’t work out real well. I figued I’d open a thread on this because I know I’ll need help…Advice would be wonderful.
var ray = camera.main.ScreenPointToRay(Input.mousePosition);
var lookPoint = ray.GetPoint(70);
transform.LookAt(lookPoint);
Debug.DrawRay(ray.origin,ray.direction * 35, Color.yellow);
var controller : CharacterController = GetComponent(CharacterController);
if (controller.isGrounded) {
// We are grounded, so recalculate
// move direction directly from axes
moveDirection = Vector3(Input.GetAxis("Horizontal") * .7, 0,
Input.GetAxis("Vertical"));
/*
transform.Rotate(0,Input.GetAxis("Horizontal") * rotSpeed,0);
*/
moveDirection = transform.TransformDirection(moveDirection);
moveDirection *= speed;
This is what I got, pretty basic just the character controller and a little mouse look function that I found a while back.
To re-iterate, how can I get this to only look o the y axis?
thanks!