Game Development Reference
In-Depth Information
trackObj = null;
}
15. Lastly, the eval() method for this condition should be implemented to
return the hasEntered variable. Recall from when we first developed the
npcCondition system that the keyword override is used when declaring this
eval() method to tell the Unity C# compiler that this implementation of the
method corresponds to the interface declared in the npcCondition base
class. In this way, we have now paired the PhysX trigger system with our
DecisionMgr. When the Is Trigger checkbox fires the OnTriggerEnter()
method even when the player or racer crosses the finish line, it will pass
the reference from the GameObject that entered the trigger to this condition
class. This can be accomplished with the following code snippet:
public override bool eval()
{
return hasEntered;
}
16. Setting our attention on the response we need to write, let's create a new
script named response_insert and add an instance of it to LeveLLo-
gicObj .
17. Modify the script so that it inherits from npcResponse rather than Monobe-
havior . Don't forget to add the [System.Serializable] flag to the
script.
18. Add a public npcCondition variable named data, as shown in the following
line of code:
public npcCondition data
19. At this point, we recognize that in our base npcReponse and npcCondi-
tion classes, we need to track the paired response or condition from the
interaction. As such, go into these classes now, and add a public condi-
tionAssociation to npcResponse and add a public responseAssoci-
ation to npcCondition .
20. Switching back to response_Insert , we start to implement the dis-
patch() method. We first get condition_OnEnter() associated with this
response's interaction and check if the GameObject that actually entered is
Search WWH ::




Custom Search