- Home /
Create GUIText by pressing key
Hello!
My Problem is, that I would like to create a GUIText when I press the "e" key. But it should only create a text if I look on the specific object. For example if I look on the rock which should "say" something and I press "e" then it should create the GUIText. I hope you understand what I mean.
Greetings
Answer by Drakestar · Jun 21, 2012 at 06:30 PM
Looking at how? Top-down, isometric, 3D view? In 3D graphics, you use the dot product of two vectors to determine how much those vectors are facing in the same direction. In this case, you'd get the dot product between your camera's facing direction and the the difference between the object's position and the camera position. Make sure you allow for a tolerance in the angle.
The documentation has an example: http://unity3d.com/support/documentation/ScriptReference/Vector3.Dot.html
Your answer
Follow this Question
Related Questions
Anyway to get what key is down? 1 Answer
Perform event only once on keypress 1 Answer
key remaping menu 0 Answers
Check the latest key pressed? 2 Answers
troubles with changing scenes 3 Answers