How do I make unit ignore targets behind solid objects (RTS)

Get help using Construct 2

Post » Wed Apr 05, 2017 6:14 pm

I'm starting with C2 RTS example and it's driving me crazy. I can't get friendly units to ignore targets that are behind solid objects.

I fixed both units not to shoot at each other while behind the walls but once the target has been seen (acquired) they are again shooting through walls.

I did manage to stop units from going over each other with a code from forum but I haven't found anything on this problem.

If anyone can help that would be great.

My capx file:
https://mega.nz/#!MfJVyayL!pNTnsuoPLfdt ... 2tz_q3My3Y
B
21
S
11
G
3
Posts: 38
Reputation: 3,358

Post » Wed Apr 05, 2017 11:13 pm

I've looked into the capx briefly and from what I could make out, the units are firing because they have LOS on the enemy (or vice-versa the friendly) even though that's not the their _current_ target.

I've screen cap'd a modification

What I did was:
-get rid of the Foreach in the Tank1Turret (I was wondering if this was necessary?)
-I picked Enemy1Base by querying the Tank1Turret.Turret,TargetUID.
-Then query if Tank1Turret has LOS on that particular TargetUID.

I test it and seemed to work. capx

(Note that I only modified the friendly turrets, not the enemy.
B
42
S
12
G
1
Posts: 74
Reputation: 2,992

Post » Thu Apr 06, 2017 12:10 am

Yes this worked out perfectly! I never would have thought of Tank1Turret.Turret.TargetUID, great solution.
Thank you, I was going crazy with this :lol:
B
21
S
11
G
3
Posts: 38
Reputation: 3,358


Return to How do I....?

Who is online

Users browsing this forum: OddConfection and 12 guests