Enemy Tank AI

For questions about using Classic.

Post » Tue Apr 27, 2010 7:18 pm

[quote="R0J0hound":2vppgw1d]+ System: While
+ System: "Solid" at (Sprite[RTS].DestX, Sprite[RTS].DestY)
-> Waypoint: Set X to Random(DisplayWidth)
-> Waypoint: Set Y to Random(DisplayHeight)[/quote:2vppgw1d]
If I use "While", then the app always crashes. Without While, it doesn't work (and the solution sounded so awesome).
And there is no "Set Waypoint X" and "Set Waypoint Y". I only see "Add Waypoint to point" and "Move to point".
B
7
S
1
G
2
Posts: 87
Reputation: 1,099

Post » Tue Apr 27, 2010 7:44 pm

Like I said in my previous post, it wont work with waypoints anyway.
But, in theory you could do as GMG suggested, and make his assumption work.
You can do that by spawning a dummy object, and setting the waypoint to the dummies x,y.
Then if the dummy overlaps the wall, destroy it, and spawn another random position.
You should keep in mind that waypoints add a ton of processing, so if you have many enemies moving around its going to bog down the system.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Wed Apr 28, 2010 1:16 pm

Ok, I made a new dummy object, now it works... almost!
The thing is, that two waypoints (dummy object) are created, when two enemies are on the screen.
Now when one of the enemies overlap the object, than it gets destroyed and another one gets created. Now both enemies follow the same waypoint and the other object gets left behind.
I'm still clueless.
B
7
S
1
G
2
Posts: 87
Reputation: 1,099

Post » Wed Apr 28, 2010 5:40 pm

Well I'm not sure exactly what your doing, but it sounds like you want two different enemies to follow two separate dummies? If thats the case you can either spawn a two different dummies IE two different objects, or two instances of the same object, and use a private variable to pick which one to follow. Something like:
dummy(pv)=1
enemy (pv)=1
->enemy add waypoint at dummy

dummy(pv)=2
enemy (pv)=2
->enemy add waypoint at dummy
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Wed Apr 28, 2010 7:19 pm

Well, I'm doing like this:
There is a spawn Object of the enemy, to make the level editing and events a lot easier.
Now, in one level there are two spawn objects and in another level there are 4 spawn objects.
So I made the event to make a new enemy sprite at the position of the spawn object and destroy it.

I made it like this, because I want to also make a Level Editor (as seen in my other thread), making things a lot of easier.
B
7
S
1
G
2
Posts: 87
Reputation: 1,099

Post » Thu Apr 29, 2010 9:47 am

Put your dummy object into a container with your enemy tank. Each tank will have their own dummy object, and picking in events should use the correct dummy. The events might get fiddly but they should work.
B
2
S
2
G
3
Posts: 105
Reputation: 1,510

Post » Thu Apr 29, 2010 6:01 pm

Not a bad idea. Just the same problem still exists. Both tanks are still following the same dummy object. While the other dummy gets left behind. Just to note, there are not two objects of tank in the layout. there is only one of them and two spawn object.
B
7
S
1
G
2
Posts: 87
Reputation: 1,099

Previous

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests