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
script with additional places to visit, including our town. We can do this simply by adding additional highlighted routes to our NavigationManager
script as follows:
public static...