- Home /
How to draw an arrow from fps contoller
hello I would like to know how to attach an arrow to show what direction the fps controller is facing. I am using the below method to get the power I will use to throw the stone. The directional arrow is so i can see what direction the fps controller is facing when I switch the camera view so i still know what direction ill be throwing the mentioned stone. The stone is an object that is thrown at targets.
void OnGUI() {
hSbarValue = GUI.HorizontalScrollbar(new Rect(25, 25, 100, 30), Mathf.PingPong(Time.time*5.0f, 19), 1.0F, 0.0F, 19.0F);
}
I would also like the arrow to change the its size depending on the power off that method.
I dont have a clue how to do this so any help would be appreciated.
Thanking you
"throw the stone" - What stone?
Please watch this and make your question clearer: http://video.unity3d.com/video/7720450/tutorials-using-unity-answers
Answer by robertbu · Feb 22, 2013 at 07:47 PM
As a starting point, scale a box to (0.1, 0.1, 1) or whatever works with your scene. You want it long on the Z axis. Place this in front of your character so that it is pointing forward. Make this a child of the game controller object. You can set the local scale of the box at runtime based on hSBarValue.
transform.localScale = new Vector3(.1f, .1f, 1.0 * factor * hSBarValue);
If this is a permanent part of the game (rather than a debugging tool), replace the box with a 3D arrow object.
this works for moving the pointer back and forth, but it starts moving my fps controller off the terrain in weird directions when i try to press a movement key Thanks for your help though
I'm confused. There's nothing here that would move the fps controller. Did you add a rigidbody to the block?
no what was happening was that the line was expanding in both negative and positive x values which was pushing the fps contoller, it worked perfectly when i moved it so it never actually touched the controller
thanks for your help
Your answer
Follow this Question
Related Questions
Mathf.pingpong 4 Answers
FPS Controller rotate between two points c# 2 Answers
turn on off particle system 1 Answer
Hide the ImageTraget in Real world 0 Answers
how to get in game numerical input 1 Answer