Making turrets target objects based on team instancevariable

Get help using Construct 2

Post » Mon Dec 28, 2015 9:45 pm

I have a problem.

I have a game with many units, but each unit has an instance variable called Team which marks what team they are on.

In this example, it's a space ship called SpaceFighter-- this is only one Object type. I do not want to clone this object type or make a duplicate object type, I want to do this using instance variables. There's two teams. Team 1 and Team 2.

So there's two SpaceFighters.

SpaceFighter 1 : Team = 1
SpaceFighter 2 : Team = 2

They fly around and also have a Turret behavior, it's great. However, adding targets has proven to be difficult.
I obviously only want SpaceFighter 1 to target objects on Team 2 and not it's own team (Team 1), but I'm not sure how to do that.


Does anyone have any ideas?
B
7
S
1
Posts: 39
Reputation: 511

Post » Tue Dec 29, 2015 11:59 pm

Going to try to get attention on this...
One band-aid solution was


Condition:
On Target Acquired check to see if it was on the same team, and if it was,
Action:
Unacquire target.


However, this led to the SpaceFighter targeting & untargeting itself and its allies 100 times per second with the off-chance that it will target an actual enemy.


This solution is not good enough. Does anyone have a workaround for me besides duplicating the objects? I plan on having 4 players, 6 races, and 20 units each race. That's 120 objects-- if I have to make each object 4 times, that's 480 objects (and behaviors, effects, etc). I can't do that.


Thanks guys.
B
7
S
1
Posts: 39
Reputation: 511

Post » Wed Dec 30, 2015 12:20 am

Put the object into a Family, so you can reference the Targeter & Targetee.
Use Pick by comparison (Targeter), where Team=1, Foreach, Pick by comparison (Targetee), where Team=2, Pick random instance. Have Targeter target Targetee.
Do the opposite for Team=2, targetting Team 1.
ImageImageImage
B
71
S
21
G
220
Posts: 3,646
Reputation: 123,721

Post » Wed Dec 30, 2015 6:18 am

blackhornet wrote:Put the object into a Family, so you can reference the Targeter & Targetee.
Use Pick by comparison (Targeter), where Team=1, Foreach, Pick by comparison (Targetee), where Team=2, Pick random instance. Have Targeter target Targetee.
Do the opposite for Team=2, targetting Team 1.


Hey, thanks for answering!

I'm going to go ahead and give this a try in case I'm misunderstanding, but I don't think I comprehend the logic behind your conditions/actions. My intended outcome is to have MANY SpaceFighters on Team 1, 2, and possibly 3 and 4, and have the SpaceFighters target either nearest or first-in-range enemies. Would your suggested solution accomplish this? I guess the "pick random instance" is throwing me off.

When I can, I'm going to try out your suggestion anyway.

Thanks for responding btw, I spent an actual 4 hours trying to figure this out.
B
7
S
1
Posts: 39
Reputation: 511

Post » Wed Dec 30, 2015 3:45 pm

Here's three teams targeting the nearest "other" teams.

http://www.blackhornettechnologies.com/ ... osest.capx
ImageImageImage
B
71
S
21
G
220
Posts: 3,646
Reputation: 123,721

Post » Wed Dec 30, 2015 7:13 pm

This is really great and I will definitely be referring to this- thank you. I do wish I could use the Turret behavior, though, as I wouldn't be able to replicate predictive aiming.
B
7
S
1
Posts: 39
Reputation: 511


Return to How do I....?

Who is online

Users browsing this forum: Google [Bot], mrkaio, Zav and 3 guests