- Home /
Gun object following mouse.
How do i get my gun to point at and follow the mouse. Also how do i get my mouse pointer to become a cross hair or something like that.
You really shouldn't ask two questions in one. Just ask two separate questions, you're more likely to get help that way. ;)
Answer by 3dDude · Jul 08, 2010 at 04:04 PM
This script makes the mouse a texture.
var texture : Texture2D;
function Start () { Screen.showCursor = false; }
function OnGUI () { var vectorx = Input.mousePosition.x; var vectory = Input.mousePosition.y; GUI.DrawTexture(Rect(vectorx-15,-vectory + Screen.height-15,30,30),texture); }
THAN$$anonymous$$ YOU. Just need the gun to follow the cross hair now grr
Do you mean have the gun aim where the mouse is? or something else
Thats exaclty what i mean. i want the tip to point at the mouse
Answer by kroltan bahuman · Oct 13, 2010 at 06:02 PM
if you're making a first-person, just drag the gun to the camera, so it becomes a child of it. childs follow a relative position and orientation from their parents. so, if the parent (in this case, the camera) moves, it will move too. remember to position the gun correctly inside the camera's field of view.
Your answer
Follow this Question
Related Questions
Mouse Aim- Weapons 2 Answers
Maximum speed mouse follow without rotation 0 Answers
Mouse Aiming Follow Wrong Direction - Help 2 Answers
Can't figure out how to get a crosshair to adjust size with mouse movement. 1 Answer
(Easy question)What am I doing wrong making my cross hair transparent? 1 Answer