How do I get previous pos (X,Y) from current Angle of Motion

Get help using Construct 2

» Thu Sep 10, 2015 8:06 am

The object I am trying to figure out the previous location of is a Bullet that uses the Bullet behavior.

An NPC needs to be able to move a set distance (say 500 pixels) toward the point (X,Y) where the bullet was created/fired from (this NPC uses Pathfinding).

I am trying to do this without taking into account the current location of the bullet (my check for the Bullet position doesn't happen every tick due to the sheer amount of bullets on the game screen at any time). So my question is - is this even possible? We know the location of the NPC and the Angle of Motion + Distance Traveled for the bullet.. how do we determine the X and Y that the NPC should move toward?

Thanks.
B
90
S
31
G
11
Posts: 101
Reputation: 11,337

» Thu Sep 10, 2015 8:17 am

give the npc two instance variables (x and y) when bullet (in question) is created store its x and y in npc.x and npc.y so you always know where you want to go ?
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,902

» Thu Sep 10, 2015 8:28 am

@RamPackWobble What X & Y would I then move the NPC to, to be within 500 pixels of the Bullets creation point?
B
90
S
31
G
11
Posts: 101
Reputation: 11,337

» Thu Sep 10, 2015 9:30 am

every now and again...

if distance (npc.x,npc,y,npcrememberedx,npcrememberedy)<500 then stop movement ?
August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
34
G
47
Posts: 1,194
Reputation: 30,902