Point and click obeying barriers

Hello everyone, just making an among us style movement for a game I’m producing at the moment.
I was wondering, in the example below, how I would enable the blue box to add as a collision, and therefore the character cannot move through it.

Here is the project as of currently.
https://playcanvas.com/editor/scene/1282949

Thank you very much!

Could it even be better to instead create a bounding box with custom boundaries? In which, the white plane size and shape would be anything, and that would be the bounding box produced?

Hi @adamburgess38 and welcome,

What you are looking for is pathfinding, the concept of finding valid paths given either a grid of valid nodes or a navmesh. PlayCanvas doesn’t provide an API for doing that so you will have to either write your own or integrate a third party library. Especially for navigating in two dimensions you can find a number of JS libraries if you search around.

Make sure to do a forum search with Pathfinding, there are some topics discussing this around.

1 Like

But if you are looking only to avoid getting valid click points when clicking on the box, you can add as you say a bounding box and check if the point is included in that.

If yes, don’t allow the player to start moving.

You can use the following method on the bounding box to check that:

https://developer.playcanvas.com/api/pc.BoundingBox.html#containsPoint

1 Like