AI and LOS problems.

For questions about using Classic.

Post » Mon Jan 03, 2011 10:26 pm

Hi.

Currently i have problems setting up a very simple ai. I have a enemy sprite with RTS and LOS behaviour. The enemy should chase the player sprite and when the player is in the line of sight(in the current cap it is 300) the enemy sprite should stop, play the shooting animation and spawn a bullet in direction of the player.

But something is wrong. The enemy chases the player but don't start shooting at the player. The enemy sprite start shooting when it arrives at the player, but this is much to late.

I think the problems must be with the private variables. So here is my cap file:

http://www.mediafire.com/file/90c6pb596 ... owTest.cap

The events for the enemy are in the enemy group in the event sheet. Maybe someone can be so nice to tell me what i'am doing wrong.

((edit: link repaired))
B
2
G
2
Posts: 15
Reputation: 680

Post » Mon Jan 03, 2011 11:57 pm

Link is broken.

Also, I heard the LOS behavior is glitchy. But maybe you should try the distance(x1,y1,x2,y2) value. for example:

[code:3usv6dop]
+System - For Each Enemy
+System - Value: distance(player.x,player.y,enemy.x,enemy.y) Lower or Equal 300
-> Set speed Enemy to [WHATEVER]
-> Enemy - Create object Bullet
-> Bullet - Set angle towards object Player[/code:3usv6dop]

At least, that's how I would do it. :lol:
B
26
S
7
G
5
Posts: 202
Reputation: 5,235

Post » Tue Jan 04, 2011 1:13 am

Thanks Phobos! This solution works without problems. I think i will use it instead of LOS.

Anyway, if LOS would work right it would be a very handy behaviour.
B
2
G
2
Posts: 15
Reputation: 680


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests