Using jumper while moving

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
rdaleg3
Prole
Posts: 1
Joined: Sun Jul 10, 2016 10:13 pm

Using jumper while moving

Post by rdaleg3 »

Hi all, I know this can be avoided by storing a start and end position in some way or another but I can't for the life of me figure it out, so here it goes.
I am trying to use jumper to have an enemy or NPC travel towards the player. However if the player moves, which the player is almost always free to do, the path would recalculate from the position of the enemy and the player. Because the path is constantly recalculating If there is anything between the enemy and the player it stops working correctly.

tl;dr how do I use jumper if my start and end positions are always changing

Thanks a ton
The idiot who can't figure this out.
User avatar
airstruck
Party member
Posts: 650
Joined: Thu Jun 04, 2015 7:11 pm
Location: Not being time thief.

Re: Using jumper while moving

Post by airstruck »

Haven't used Jumper, but if the path is often blocked for just a short time, couldn't you store the last good path and keep using it if no new path is found, and only update it when a new path is found? In other words, recalculate the path whenever you need to, but store the result in a temporary local variable first, and don't update the path your guy is following with that value unless it's valid. Clear the path out when he hits an obstruction and until then let him follow it. Maybe if an old path gets too stale, clear it and let the guy wander around or whatever he normally does when he has no path to follow.

If that's not useful, it might help to post some code ;)
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 1 guest