Turret behavior - only target if other target is there

Get help using Construct 2

Post » Mon Mar 03, 2014 9:30 pm

I have a rather specific issue.
Its kinda hard to describe so i have made a small capx to try to explain.
https://dl.dropboxusercontent.com/u/2560922/mobiledev/forum/turretBehaviorHelp.capx

Image
The "shooter" object is a bullet with turret behavior

It can target both enemy1 and enemy2, but here is my dilemma. I only want it to target enemy1 if enemy2 is in front of the shooter, and only the closest instance of enemy2, it should ignore the other enemy2 far to the right.

If enemy2 is not present next to enemy1 the shooter object should continue its bullet course straight forward and ignore enemy1.

Anyone have any ideas?
B
20
S
6
G
4
Posts: 347
Reputation: 4,451

Post » Tue Mar 04, 2014 6:58 pm

It's hard to understand the reason of the comportment you describe.
Thus, I'm not really sure I understand.
But I read this as:
if shooter has in range enemy1 and 2 enemy 2, it should first target enemy 1 if enemy 2 isn't on the back of the shooter (?), else, the closest enemy2... Still feel kind of weird.
B
66
S
22
G
14
Posts: 1,484
Reputation: 16,511

Post » Tue Mar 04, 2014 10:10 pm

@yann Sorry for the lack of clarity in my explanation. I was trying to keep it simple, but it probably got to simple.

Enemy2 is actually a wall.

if you run the capx you can see that the shooter will move forward until it find its first target which will be enemy1.

The thing is that i only want the shooter to stop and shoot enemy1(the red ball) if the wall(enemy2) is up. If the wall is gone/destroyed then the shooter should continue through the gap between the 2 enemy1's.
Image

Hope that made it a bit more clear. otherwise let me know :-)
B
20
S
6
G
4
Posts: 347
Reputation: 4,451

Post » Mon Mar 10, 2014 10:36 am

See if you can work it out with this CAPX
You do not have the required permissions to view the files attached to this post.
B
250
S
39
G
15
Posts: 1,953
Reputation: 40,623

Post » Mon Mar 10, 2014 10:16 pm

@Lordshiva1948

Thx for the try. for me that makes the shooter jump to the location of enemy one (when i run it at least) which is not what i wanted.

I actually solved it by using the line-of-sight behavior.
I made an object behind the wall and if the shooter has line of sight on that object it will not attack the enemies but go between them.
B
20
S
6
G
4
Posts: 347
Reputation: 4,451

Post » Mon Mar 10, 2014 10:23 pm

Could you not just set a boolean (false if no wall true if wall - set at an appropriate time) and use this to decide on the attack action?
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
33
G
47
Posts: 1,194
Reputation: 30,832

Post » Mon Mar 10, 2014 10:25 pm

Well in principle i could, but the walls move around, so i would then have to keep track of where the walls are and where they are not. The line-of-sight thing is more flexible.
B
20
S
6
G
4
Posts: 347
Reputation: 4,451

Post » Tue Mar 11, 2014 10:40 am

CVP nice work I am glad you work it out good luck in future
B
250
S
39
G
15
Posts: 1,953
Reputation: 40,623

Post » Tue Mar 11, 2014 10:42 am

@lordshiva1948
Thank you. And thank you again for taking the time to look at the topic. Always nice with some input :)
B
20
S
6
G
4
Posts: 347
Reputation: 4,451

Post » Tue Mar 11, 2014 10:44 am

CVP you welcome we are here to help. Ask anytime if we can help we will good luck
B
250
S
39
G
15
Posts: 1,953
Reputation: 40,623


Return to How do I....?

Who is online

Users browsing this forum: jorgmaquoi and 20 guests