Hi!
I'm trying to create a sidescrolling shooter game mechanic, but I don't know how to create a GUI crosshair and don't know how to make my character point it's gun at the crosshair at all times! Please help and thanks in advance :)
Hi!
I'm trying to create a sidescrolling shooter game mechanic, but I don't know how to create a GUI crosshair and don't know how to make my character point it's gun at the crosshair at all times! Please help and thanks in advance :)
To make the crosshair (assuming that you want to make it follow the cursor), you would probably want to use GUI.DrawTexture:
This goes outside your functions, load it with the cursor image in the Inspector:
var cursor : Texture2D;
Then in OnGUI:
GUI.DrawTexture(Rect(Input.mousePosition.x, Input.mousePosition.y, cursor.width, cursor.height), cursor);
And in Update:
GunObject.transform.LookAt(Vector3(Input.mousePosition.x, Input.mousePosition.y, 0));
I'm not 100% sure on that 0, but it would be something along those lines, I think.