Turret Behavior

Get help using Construct 2

Post » Tue May 28, 2013 6:43 pm

Hey guys, so I'm adding some turrets to my game. And I get the basics of how they work. Very cool.. But something I'm trying to do I cant figure out. I want to shoot a different projectile depending on what enemy is targeted. Is there a way to do this? Basically I have it locked on to a family of enemies, but I want it to check if the enemy is a person, or a vehicle, and shoot the proper projectile. Can this be done?
B
36
S
5
Posts: 156
Reputation: 3,310

Post » Tue May 28, 2013 8:50 pm

Simple, make instance variable for the enemies and check them on the Turrent before shotting.
Image
B
104
S
23
G
17
Posts: 1,350
Reputation: 22,028

Post » Tue May 28, 2013 9:00 pm

[QUOTE=TELLES0808] Simple, make instance variable for the enemies and check them on the Turrent before shotting.[/QUOTE]

Ok, wait. That seems easy enough. But since I'm targeting a family, how do I have it check what its targeting?
B
36
S
5
Posts: 156
Reputation: 3,310

Post » Tue May 28, 2013 9:23 pm

I feel like I'm missing something incredibly simple ha ha.
B
36
S
5
Posts: 156
Reputation: 3,310

Post » Wed May 29, 2013 6:35 pm

Ok, I figured it out. I was correct, I was missing something super simple. Thanks a ton!!
B
36
S
5
Posts: 156
Reputation: 3,310

Post » Fri May 31, 2013 5:23 am

Well, now Ive run into a different issue. If both kinds of enemies are on the screen, it just fires both projectiles. Did I mess something up, or is there a way to fix this?
B
36
S
5
Posts: 156
Reputation: 3,310

Post » Fri May 31, 2013 8:31 am

[code]TurretSprite | On Turret Shoot | Spawn the bullet[/code]
(like normal)
Make a sub-event inside that event so that the right turret is currently picked:
[code]Enemysprite | Pick Instance with UID TurretSprite.Turret.TargetUID | set color[/code]

That is, Pick by UID in the target sprite, then enter for the UID the turret sprite's "TargetUID" expression. Then, the proper target will be picked, and you can set the color or frame.Paradox2013-05-31 08:37:21
B
226
S
60
G
33
Posts: 902
Reputation: 39,989

Post » Fri May 31, 2013 9:40 pm

Yeah, Im missing something still haha. I normally can whip this stuff right out. I dont know why this is stumping me.This is what I have.

https://www.dropbox.com/s/uk5mch0zkhqjumm/Capture.PNG
B
36
S
5
Posts: 156
Reputation: 3,310

Post » Sat Jun 01, 2013 12:35 am

That looks like a variation of what I said, it's not working?
You shouldn't need the "Turret has target" conditions, as it's in an event triggered by "on shoot", so there is only one turret picked. But that shouldn't keep it from working.

Hmm, I just converted the turret demo to something similar, and the Family isn't picking right. I set it to pick the enemies directly and it worked. I don't use families often, maybe I did something wrong.

Here I went ahead and saved my test capx:
https://www.dropbox.com/s/xwvmqpyull4qs72/TurretMultiBulletTest.capx

It's the demo for turrets that come with Construct, converted to use families, and multicolored bullets.

But as you can see in Events 16 and 17, the family (disabled) version doesn't work.Paradox2013-06-01 00:47:14
B
226
S
60
G
33
Posts: 902
Reputation: 39,989

Post » Sat Jun 01, 2013 6:35 am

Thanks a ton for the help. I used a slightly modified version of that to get it working. You're a life saver haha.
B
36
S
5
Posts: 156
Reputation: 3,310

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 13 guests