Page 1 of 1
Moving The Selection Text Panel
Posted: Thu Jan 27, 2022 8:16 pm
by PayasoPrince
Hello,
Rather than have the Selection Text Panel appear at the top of the screen saying "spacebar to interact" I would like it to position itself directly above the NPC I am able to interact with.
Is there an out of the box way to accomplish this?
Should I attach a script updating its position every frame?
Kind regards,
Re: Moving The Selection Text Panel
Posted: Thu Jan 27, 2022 8:32 pm
by Tony Li
Hi,
There are two ways to do that:
1. Add a Selector Follow Target component to the same GameObject as the Selector. Make sure the Selector GameObject also has a Selector Use Standard UI Elements component. Selector Follow Target will position the main selector over the NPC in screen space.
2. Or add an instance of the Basic Standard Usable UI prefab to the NPC. (See the last part of the
Interaction Tutorial.) This lets you position a world space panel exactly where you want for each NPC and customize the panel's appearance for each NPC.
Re: Moving The Selection Text Panel
Posted: Thu Jan 27, 2022 9:05 pm
by PayasoPrince
Hi, Tony
I believe I am misunderstanding.
I have added "Selector Follow Target" & "Selector Use Standard UI Elements" to the "Basic Standard UI Selector" prefab. Example:
This does not appear to be working. Is this incorrect?
Re: Moving The Selection Text Panel
Posted: Thu Jan 27, 2022 9:14 pm
by Tony Li
Hi,
Add those components to the GameObject that has the
Selector or
Proximity Selector component -- typically the player GameObject.
The Dialogue Manager GameObject has an Instantiate Prefabs component that, by default, instantiates the Basic Standard UI Selector Elements prefab into the Dialogue Manager's Canvas.
If you use Selector Follow Target, I recommend duplicating the Basic Standard UI Selector Elements prefab and assign the duplicate to Instantiate Prefabs instead of the original. Then customize your duplicate. To get the sizing right, you can remove the Reticle In Range and Reticle Out Of Range child GameObjects, and size the Main Selector Panel's height so it just fits the Selection Text Panel.
Note: If you use the world space Basic Standard Usable UI prefab on an NPC, you don't have to do any of the above.
If you haven't watched the
Interaction Tutorial yet and have a few minutes, it should clarify a lot of that.
(Also: The whole Selector / Proximity Selector system is entirely optional. It's handy, and many games use it, but if you already have your own interaction system that you prefer, you can use that instead. Just configure your interaction system to call GameObject.SendMessage("OnUse") on the interaction target.)
Re: Moving The Selection Text Panel
Posted: Thu Jan 27, 2022 10:07 pm
by PayasoPrince
Adding the components to the player resolved this. Thank you.
Re: Moving The Selection Text Panel
Posted: Thu Jan 27, 2022 10:18 pm
by Tony Li
Glad to help!