Topdown AI workaround help

» Sun Aug 03, 2008 10:58 pm

I've allready posted this problem in a thread in the uploads forum, but it seemed a little missplaced so i figured i'd repost it here.

What i'm trying to achieve is simply a remake of Ashleys Perfect topdown shooter AI, ( posted here; viewtopic.php?f=16&t=1378 the third frame in the .cap) but without the badass math and in a way that normal people can understand.

I've figured out exactly how to do it, and i've programmed it as it should be. Now i have just one problem. It doesn't work. Why? I don't know. So have a look at this .cap and read the comments and then tell me what you think is the problem. I've checked it so many times now that i'm starting to think it's not my fault. Some things (like the cross showing on the same position as the player) really indicates that a bug is hiding somewhere, but it might as well be a stupid mistake.

http://www.mediafire.com/?jwurdaalaam

B
8
S
2
G
5
Posts: 744
Reputation: 3,288

» Mon Aug 04, 2008 3:55 pm

Firstly a quicker way to move an object forward 1 pixel is to use the new 'Move at angle' action: move 1 pixel at .angle will do the trick.

Secondly, the distance between the two objects is unlikely to ever be identical. Because you move in units of 1 pixel, the closest it might ever get is 100.5 and 100.7, for example. Distance() returns a floating point value which, due to rounding errors and all that, will very rarely satisfy equality.

Change it to "Greater or equal" and it works (but still kinda weirdly). Still, I've already implemented a 'LinearAim' expression in the next build which does the perfect aim maths for you, so you can do it with a non-iterative approach and without nuts and bolts maths
Scirra Founder
B
362
S
216
G
75
Posts: 23,064
Reputation: 180,315

» Tue Aug 05, 2008 12:52 am

Sweet! But i still wonder why the cross is shown at the character, when it should be looped 1000 pixels forward..
B
8
S
2
G
5
Posts: 744
Reputation: 3,288