Turret Behavior

0 favourites
  • 11 posts
  • 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?

  • Simple, make instance variable for the enemies and check them on the Turrent before shotting.

  • Simple, make instance variable for the enemies and check them on the Turrent before shotting.

    Ok, wait. That seems easy enough. But since I'm targeting a family, how do I have it check what its targeting?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I feel like I'm missing something incredibly simple ha ha.

  • Ok, I figured it out. I was correct, I was missing something super simple. Thanks a ton!!

  • 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?

  • TurretSprite | On Turret Shoot | Spawn the bullet

    (like normal)

    Make a sub-event inside that event so that the right turret is currently picked:

    Enemysprite | Pick Instance with UID TurretSprite.Turret.TargetUID | set color

    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.

  • 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.

    dropbox.com/s/uk5mch0zkhqjumm/Capture.PNG

  • 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.

  • Thanks a ton for the help. I used a slightly modified version of that to get it working. You're a life saver haha.

  • Hey the new r135 update just fixed this family picking thing, it was a bug.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)