[SOLVED] Control Point. Algorithm

Hello. I’m working on a third-person shooter. There is a control point in my project, which is a kind of arena. I need to implement the following logic. When a player enters the arena zone, the points counter runs. When a player jumps above the arena, the points counter continues to count. When a player leaves the arena zone, the counter stops. The only thought that occurred to me was to make Ray Cast down the player and check the entity that was discovered. If the entity is an arena, then execute the appropriate code. Tell me, please, how to make the algorithm correctly?

There are a few ways to do this. Raycasting the floor can work. The other is to use region boxes and check if the player is in the region or not (PlayCanvas has shapes which can handle point in shape checks https://github.com/playcanvas/engine/tree/master/src/shape)

I have not found such a component in the editor. Should I create an entity and add via script, for example, Bounding Box?

There’s an example of use here https://developer.playcanvas.com/en/tutorials/simple-shape-raycasting/

That one uses raycasting but as you can see from the engine code, there are other functions you can use.

1 Like

Thanks for the help. I will use the .containsPoint() method to find a point inside the bounding box.