I have set up a node as a trigger to detect when the player reaches the area. I create a CollisionShape component, expand its size in X and Y to cover the desired area, then add a RigidBody, set its Collision Event Mode to Always and enable Trigger checkbox. Also added an StaticModel (the box), just in case, and make it invisible by unchecking all the View mask checkboxes.
In the player creation code I have this:
node = scn.CreateChild(id);
model = node.CreateComponent("AnimatedModel");
body = node.CreateComponent("RigidBody");
shape = node.CreateComponent("CollisionShape");
shape.model = model.model;
In the gameplay code I subscribe collision event and set up a basic handler:
SubscribeToEvent("NodeCollision", "HandleTriggers");
***
void HandleTriggers(StringHash eventType, VariantMap& eventData)
{
Node@ n = eventData["OtherNode"].GetPtr();
Print("collided with "+n.name );
}
But when I make the player model walk to the area, nothing happens. Is there any missing step in the shape and body creation?