Pathfinding leading to erratic teleportation

This object uses the pathfinding behaviour to follow my character, but whenever I move near objects for pathfinding, the objects move to different positions randomly.

Preview of the project (the recording software was laggy)
https://drive.google.com/file/d/1P3qg_Id81I3pKQ83Ajrn1A9F1fIoEYSu/view?usp=sharing


The object’s movement events


Settings for the object’s Pathfinding behaviour


Settings for the Object for Pathfinding

I also tried making the object passible but with a high cost and seperating the objects when they collide with each other

Why are you picking all Player objects? Is there more than 1?

[edit]
I’d look into looping through all the enemies and running the find path action on each one, rather than all at once. That way you can also check the path was found.


Was this what you meant? If so, I don’t think it worked.

I picked all Player objects because if I didn’t, the Monster’s would pathfind to (0,0).
I’m pretty sure the pathfinding works well, its just when I repeatedly walk around a corner, they seem to clip into the wall and teleport.

Do you have more than one player object? If not you need to eemove that pick all condition, it will break the rest of your events because it is deselecting your monster onject and defeats the purpose of for each.

If you are pathfinding to 0,0 and only have one player object, there is a separate issue going on.

To check for more than one payer object, in the scene editor click on the “Open the list of instances” icon on the top right. scroll through and check only one instance of player object.

If you don’t have more than one player object, try setting the monster’s pathfinding behaviour to:
extra border size:10, virtual cell width & height to the size of your monster.

Seconded.

I checked the list of instances, there was only one.
It can work without “Pick all Player Objects”, if I store playerX and PlayerY in a variable

I changed the monster’s pathfinding behaviour, and it seems to work better although it still teleports.

I tried removing the raycasting and making it always pathfind and it no longer teleports.
For now, I will probably leave it like that - it was probably how I made the raycasting events that caused it.

Why do you need to store them in variables? Just access them directly in the pathfinding action.


What raycasting? That’s not in the snippet you provided.

If you need help getting the raycasting working, start up another thread. It’s not always that easy the first time you use it.

When I access them directly, the monsters pathfind to (0,0).

The first image I provided has the raycasting events

My bad, I should have looked closer at it :unamused:


That may affect performance, but it could be negligible and undetectable. Good to see you found a reasonable solution

1 Like