- Home /
Look at mouse?
What I am trying to do is from a eagle eye view make my character point in the direction of my mouse, I am currently using the MouseLook script from the fps controller but this dosent work in the way which I want. Can anyone help me out?
I believe the AngryBots demo has the type of controls you're looking for - perhaps try using/learning from that script? The player rotates towards the mouse: http://www.youtube.com/watch?v=x$$anonymous$$aA6yRSDXk You can download the demo from the main unity site, don't know whether this is what you're looking for though.
You could properly use something simple as 'transform.LookAt(Input.mousePosition);' Not quite sure what you are going after here.
Answer by Dreave · Dec 23, 2011 at 09:03 PM
I found this script which works fine, thanks for the help though.
 function Update() {
   var playerPlane = new Plane(Vector3.up, transform.position);
   var ray = Camera.main.ScreenPointToRay (Input.mousePosition);
   var hitdist = 0.0;
   if (playerPlane.Raycast (ray, hitdist)){
       var targetPoint = ray.GetPoint(hitdist);
       var targetRotation = Quaternion.LookRotation(targetPoint - transform.position);
       transform.rotation = targetRotation;
     }
 }
Hi! This is exactly what I'm looking for, but what if I wanted to rotate the X-axis aswell, not just the Y-axis?
Your answer
 
 
             Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
A node in a childnode? 1 Answer
Save Position script. 2 Answers
C# Non-Static Member Rigidbody2D.MovePosition 1 Answer
Script for tank fire 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                