Friday, March 3, 2017

Day 20: Dialogue System and Interactions

First of all, I needed to add to the script to prevent the player object from interacting with an object until it is within a certain range.

Well this is a problem. It appears to be calling the "Interactable" function infinitely many times until I stop it. I need to find a way to only call the function once.

To solve that problem I added boolean called "hasInteracted". When the player starts moving, it is set to false. When it reaches the interaction distance, it is set to true. So since the "Interact" function is only called if "hasInteracted" is false, then it only calls the function once.

After adding a "!" just before "hasInteracted && playerAgent != null...", it worked perfectly!

Now I can finally set up the dialogue UIs. First, I started with a simple panel, which I called "Dialogue".

I then scaled the panel down (it was taking up the entire screen), and added a button labeled "continue".

Then I added another, smaller panel, with the text "Name". And that is the basic dialogue UI. I imagine the tutorial will have me add some scripts that show the dialogue and name based on what I'm interacting with. I will continue the tutorial next class.

No comments:

Post a Comment