Unlock Event
Last updated
Last updated
I have added a Unity event call for when you get the code correct
Click the little + icon in the bottom right, it will add a new event and you can place any gameobject which may have a script with a public method you want to call.
In this case I have added the door object, this has a script called DoorController which has a public method called PlayAnimation
You can then run this code each time you unlock something, this can be changed on each door, and multiple events can happen in each! Making life really easy! (If you need any help do let me know).
Using the UnityEvent feature on each controller will allow you to add multiple event types, see the demo scene for a clear example on this!
In the example below you can see the event plays the animation from the script DoorController which exists on the actual door object itself. Only when the code is correct can we run it.
I have also added a RemoveTag script in case you want to remove the tag to stop interaction with the keypad once you get a specific code.
See the Scripts > Event Examples folder