- Home /
Object Interaction
Hello I am currently creating object interaction script using raycast method but I dont know how to keep the GUI label on the same location on the object even if the player moves towards it. For example "Press E to interact" that is always on the same spot over the object. should I use spirtes instead and rotate them accordingly?
Answer by weltraumaffe · Sep 01, 2013 at 03:02 PM
You should either use a GUI (and transform the WorldCoordinates to ScreenCoordinats and draw a label there).
Or you should make the gameobject with the text a child of the object where it should be seen. As for the rotation in this case: Make a script that takes the rotation of the player camera and apply it to the object with the text (use the WorldRotation not the local ...)
thanks for the reply, the rotation is recalculated every time the player moves right?
The rotation is recalculated every frame if you put it in the Update()
method.
With the GUI it is recalculated everytime OnGUI()
is executed (This can multiple times per Update()
)