Game Development Reference
In-Depth Information
Updating the NavigationPrompt script
The map points we have defined are set as triggers. We use triggers when we do not want
any physics interactions between the collider and other rigid bodies; all we want is to be
notified that one collider has moved over (in the case of 2D) or interacted with another
collider.
As we are now using triggers, we need to swiftly update our NavigationPrompt
script to work with triggers. So, open the NavigationPrompt script and add the fol-
lowing function in it:
void OnTriggerEnter2D(Collider2D col)
{
//Only allow the player to travel if allowed
if (NavigationManager.CanNavigate(this.tag))
{
showDialog = true;
}
}
The function in the preceding code does exactly the same as the OnCollisionEnter-
2D function, which we already have, but this will now respond to the colliders that have
been set as triggers using the is Trigger flag.
Search WWH ::




Custom Search