October 2016
Beginner
506 pages
10h 1m
English
Since the town and campsite have their Box Collider 2D components set as triggers, we need to swiftly update our NavigationPrompt script to work with triggers. So, open the NavigationPrompt script and add the following function to it:
void OnTriggerEnter2D(Collider2D col){
if(NavigationManager.CanNavigate(this.tag)){
Debug.Log("attempting to exit via "+ tag);
NavigationManager.NavigateTo(this.tag);
}
}
The function in the preceding code does exactly the same as the OnCollisionEnter2D function, which we already have, but this will now respond to the colliders that have been set as triggers using the is Trigger flag.
As the player can now venture out of town, we need to update our NavigationManager ...
Read now
Unlock full access