# \[SOLVED\] Control Point. Algorithm

**URL:** <https://forum.playcanvas.com/t/solved-control-point-algorithm/8927>\
**Category:** Help & Support\
**Created:** [January 14, 2019, 12:50pm UTC](https://forum.playcanvas.com/t/solved-control-point-algorithm/8927 "2019-01-14T12:50:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MasalovAndreey](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/masalovandreey/32/7325_2.png) [@MasalovAndreey](https://forum.playcanvas.com/u/MasalovAndreey)\
**Post date:** [January 14, 2019, 12:50pm UTC](https://forum.playcanvas.com/t/solved-control-point-algorithm/8927/1 "2019-01-14T12:50:19Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![yaustar](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/yaustar/32/2268_2.png) [@yaustar](https://forum.playcanvas.com/u/yaustar)\
**Post date:** [January 14, 2019, 2:44pm UTC](https://forum.playcanvas.com/t/solved-control-point-algorithm/8927/2 "2019-01-14T14:44:20Z")

</div>

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](https://github.com/playcanvas/engine/tree/master/src/shape))

---

<div class="post-metadata">

**Author:** ![MasalovAndreey](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/masalovandreey/32/7325_2.png) [@MasalovAndreey](https://forum.playcanvas.com/u/MasalovAndreey)\
**Post date:** [January 15, 2019, 4:04am UTC](https://forum.playcanvas.com/t/solved-control-point-algorithm/8927/3 "2019-01-15T04:04:42Z")

</div>

I have not found such a component in the editor. Should I create an entity and add via script, for example, [Bounding Box](https://developer.playcanvas.com/en/api/pc.BoundingBox.html)?

---

<div class="post-metadata">

**Author:** ![yaustar](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/yaustar/32/2268_2.png) [@yaustar](https://forum.playcanvas.com/u/yaustar)\
**Post date:** [January 15, 2019, 10:00am UTC](https://forum.playcanvas.com/t/solved-control-point-algorithm/8927/4 "2019-01-15T10:00:34Z")

</div>

There’s an example of use here [https://developer.playcanvas.com/en/tutorials/simple-shape-raycasting/](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.

---

<div class="post-metadata">

**Author:** ![MasalovAndreey](https://forum.playcanvas.com/user_avatar/forum.playcanvas.com/masalovandreey/32/7325_2.png) [@MasalovAndreey](https://forum.playcanvas.com/u/MasalovAndreey)\
**Post date:** [January 15, 2019, 10:30am UTC](https://forum.playcanvas.com/t/solved-control-point-algorithm/8927/5 "2019-01-15T10:30:49Z")

</div>

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