- Home /
Duplicate Question
rotare arrow object to mouse position
i would like rotate arrow withface into mouse motion, how to rotate it?
this my code., its rotate ,but not facing pointer position. thanks before :)
 using UnityEngine;
     using System.Collections;
     
     public class arrow : MonoBehaviour {
          
       float speed = 1.0f;
     
         // Use this for initialization
         void Start () {
           
         }
         
         // Update is called once per frame
         void Update () {
            transform.Rotate (new Vector3( 0, Input.GetAxis("Mouse X"),0),60 * Time.deltaTime * speed);
     
         }
     }
 
![alt text][1] [1]: /storage/temp/22346-untitled.png
This question has been answered many times and in many different ways. The solution is highly depending the environment and the game object you are rotating.
- Is this a 2D or 3D rotation? 
- If 2D, what kind of object is being rotated: Quad, Sprite, 3D object. 
- If 3D is the side facing positive 'z' considered forward? 
- If 3D is the camera rotation (0,0,0)? 
- If 3D and the rotation is not (0,0,0), is is axes aligned (and if so where is the camera facing. 
Do some searching. If you find what you believe is a workable solution but cannot get it to work, open a new question with the code you are struggling with.
Note in your code above you are using Screen coordinates in a World coordinate situation.
Follow this Question
Related Questions
Moving objects in game using .transform does not stop 3 Answers
rot not working for 2nd prefab 2 Answers
object rotates when moving backward 1 Answer
Setting Position of Spawned Prefab 2 Answers
Transform.Rotate() problem : Avoid Z-axis rotation ? 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                