custom entity and map limit

Started by Yosha, August 28, 2018, 10:06:05 AM

Previous topic - Next topic
Hello,

I was wondering if it was another way to make custom entity go outside of the map limits. For the moment, I use movement:set_ignore_obstacles() with some positions test to make them go out and in but I wanted to know if there was another collision test with maps limit. I tried custom_entity:set_can_traverse_ground with empty ground but as I expected it doesn't work !

My problem is that I wanted that my custom entity (or npc) go outside and inside the map, but if I two of these entities walk in the same position (or if the 2 bounding box overlaps), they will be stucked if I set movement:set_ignore_obstacles() to false when they enter the map. And I can't let it to true, otherway they will not be obstacles in the map.

If someone has a solution, it would be great !
Thanks.

This does not seem trivial. I would try this:
1) Use "entity:on_obstacle_reached(movement)" to see when the NPC finds an obstacle and then check if the NPC is at the border of the map and looking outside (usethe bounding box coordinates and NPC direction). You can also do this with "on_position_changed", but it requires more work.
2) Then, use "set_ignore_obstacles()" to allow the NPC enter or go out of the map.

You can make a script to define an initialization function on NPCs (that is, to define this function in 1 line for each NPC), so that you avoid repeating code.
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."

Thanks, but my problem is when 2 npcs (or custom_entities in my case) go out or enter the map at the same time (and at the same place of course). I already make them leave or enter the map, and there's no problem here. But as the set_ignore_obstacles() parameter is true, they are passing through each other. And the result of this is odd.