- Home /
object to point at mouse based on mouse position
I need the object to aim at the mouse. Like a side Scrolling shooter would. right now it "Moves"....but not really where the mouse is. This is what i have for code.
var speed : float = 1.0; //how fast the object should rotate
function Update(){ transform.Rotate(Vector3(Input.GetAxis("Mouse Y"), Input.GetAxis("Mouse X"), 0) Time.deltaTime speed); }
that is on my gun object. I think i need to also change the rotate point on my gun any idea on how i would do that?
thanks alot Karl
http://www.youtube.com/watch?v=2lpZLcELFTI Here is a video to what is happening. Please HELP!!
yet another duplicate question: http://answers.unity3d.com/questions/14792/gun-object-following-mouse
@$$anonymous$$arl, please stop repeating the same Question. Take @SpikeX's advice, and learn Unity. If you don't want to bother even doing a tutorial, why should we bother to write your code for you?
well i thought this was UnityAnswers not unity we will give you links for tuts.com
@$$anonymous$$arl, @SpikeX gave you an answer - Transform.LookAt() will do what you want.
Answer by qJake · Jul 08, 2010 at 10:14 PM
I think you're looking for Transform.LookAt(). You call this on the object that you want to rotate, and you give it a Vector3 point in 3D space where you want the object to rotate to.
Do you have the code i need to use. Im really new at this.
If you're new, take the time to learn. Unity isn't a toy, it's a professional game development tool, and if you expect to learn it overnight, you are sorely mistaken. I'm not going to give you working code, you need to figure it out on your own, that's how you learn. See this question for a list of tutorials: http://answers.unity3d.com/questions/4897/how-can-i-start-learning-unity-fast-list-of-tutorials
im an artist, im trying to put together a game i have everything in my game working accept this. I really dont feel like going threw a whole tut.
Your answer
Follow this Question
Related Questions
How do you make your main Character jump into a car 1 Answer
I am trying to Randomize my Answers? 1 Answer
circular progress bar 1 Answer
Game stuck and crash while playing 0 Answers
How to keep my character from falling through the floor? 0 Answers