- Home /
How make an Interaction with object like the last of us?
Hi these days, I'm playing the last of us, one of my favourite small feature is like the game make clear which objects are important. Creating a small white circle infront of them, and then when the player can interact the internal part of the circle became a texture of which button the player has to press to interact.
http://www.youtube.com/watch?v=HawhjjF5qFc
in that link is visible from minute 3.00.
However my question is anyone has an idea about how to create a similar effect in unty?
Answer by BPR · Jun 18, 2013 at 09:43 AM
Well that are basically just Textures which are blended over the mesh, a simple but dirty approach would be using two cameras, the first one does show the normal gameview everthing except the buttons/textures, the second one has a higher priority (depth!) and is therefore shown above the other camera and can see only the textures/buttons. As for the textures/buttons you are using planes with a transparency shader and a texture showing either a white circle or the button to be pressed. Obviously in your texture file anything but the cricle button has to be transparent, use a file format which supports transparency! These planes are positioned close to the objects to interact with in the scene. That's it! You can finetune the entire thing by for example setting the second camera to orthographic so the buttons/textures have always the same size no matter how far away you are and using scripts on the planes to always rotate them so they face the player. Also you can adjust their visibility/content with scripts.
Regards, BPR
Another more simple approach would be to use the Camera.WorldToScreenPoint(yourObjectPosition) and then draw a GUI at the x and y pos returned by the aforementioned function.
Vector3 screenPos = Camera.mainCamera.WorldToScreenPoint(someVector3);
GUI.DrawTexture(new Rect ( screenPos.x, screenPos.y, 20, 20), yourTexture);
Your answer
![](https://koobas.hobune.stream/wayback/20220613104406im_/https://answers.unity.com/themes/thub/images/avi.jpg)