Trouble with Turrets [Solved]

  • Hi there,

    I'm doing some work on a tower defense style game and i see the turret temple, but i'm still not seeing how i can have one turret on the screen and each behave independent..

    the issue i have is that when my turrets spawn bullets which shoot towards their target, one turret alone is fine because i set angle for the bullet and it shoots in that direction.. but if I add a 2nd turret, they are both targeting different targets, but all bullets move the same direction rather than each firing in their own correct / independent direction.    

    I suspect this is going to be a much bigger revelation than just turrets, but this seems like a good example to start with.

    Thanks!

    Caleb

  • seems like you need to read up on how picking objects works. There are some great examples in the FAQ.

    It's all about telling the computer which turret or bullet should react to the event you made.

  • Hey that's great. Where is the FAQ? I would love to know more about how picking objects works in Construct 2.

    Maybe if anyone happens to see the Turret Defense Template they could quickly explain how those turrets are clones of each other, but able to behave independent of each other and tell individual bullets which direction to fly.

    Thanks!

    Caleb

  • part12studios

    Hi there! Just wanted to say I have the very same problem in my project.

    I'm totally gonne note you once I manage to make that work!:)

  • As far as I can see in the turret example the bullet angle isn't set. The turret automatically aquires the target as specified in the turret behaviour. Just add the target in an event and all should work.

  • Hey hey!

    @part12studios , I think i have some good news! :D

    It might be messy and needs optimisation, but.. Here, catch the capx!

    Hope that helps!:) I'll be glad to answer any questions. <img src="smileys/smiley9.gif" border="0" align="middle">

  • Hey hey!

    part12studios , I think i have some good news! :D

    It might be messy and needs optimisation, but.. Here, catch the capx!

    Hope that helps!:) I'll be glad to answer any questions. <img src="smileys/smiley9.gif" border="0" align="middle">

    Your capx is asking for a password.

  • DrewMelton

    Aww, my bad. Fixed it :)

  • ok yea now see that is what i'm talking about! i'll pick it apart further to be sure i really understand it (I.E. actually make my game do the right thing). What mystifies me though is that while you're doing it in a way that makes some sense, how did they get their tutorial to work.. i'll have to investigate further. :)

    Thanks!

    Caleb

  • Also for anyone who wants to see exactly what i'm seeing here is a link to the project dropbox.com/s/u20cq4809ao2ds7/TD_Test_1.capx

    I should have included this sooner.. see how the turrets track as they should but the bullets seem to be conflicted.

    I'm trying the method JJList made now. I just can't figure out what the template version achieves the same effect with a bit less work.

    Regardless I do like having a better understanding of how to utilize UID.

    Thanks!

    Caleb

  • the turret behaviour automaticaly sets the right bullet direction on shoot so setting the bullet angle conflicts with the behaviour. Actually the turret behaviour uses predictive aim, so the bullet will fly to where the enemy will be if he keeps moving in the same direction at the same speed.

  • okay, first question.. what is the green loop icon? you have it next to system in several places. That is new to me. I guess it's related to "for each" but i don't see why this would have an icon where other actions don't. Is there something special about it I should know?

    another thing. you have a system/else on line 3 all by itself. seeing it as it is by itself, i am surprised to see that works. wouldn't the else need to be linked to something to know what the other option is or is it simply that because it's the next function below the 2 line that it works?

    So you use this "for each" function, is this a key part of how you differentiate the saving of UID's to each tower individually?

    You use TargetUID for both Tower and Bullet. Is this needed or could they have been named uniquely?

    Also I noticed that you're not using the turret behavior stuff. As you can see in my prior capx, its about having a turret rotate and point to the target and i'm not sure if that would effect anything with your approach.

    Sadly after having gone through it to try and reproduce what you made in yours somehow it didn't work. I've attached the project here if you want to see what i did.

    I have to say this IS a very advanced / complex way to solve this problem. very impressive, but for noobs like me its a clearly easy to mix something up.

    here is the project dropbox.com/s/jt6g4icsdokxrx5/TD_Test_2.capx

    the only difference i can see is that i have two enemies on the screen already where you spawn an enemy from a spot. i'm not sure if that would matter.

    Sincerely,

    Caleb

  • LittleStain in it's simplest form, i have a have to have a bullet behavior on the bullet object or it doesn't move.

    when i add the unaltered basic bullet behavior, the bullet shoots to the right regardless of turret rotation.

    So I'm just not seeing where the turret is telling the bullet what direction to go.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • booya! ok now that makes sense and it IS great to see that the tutorial points out that this is unique to this particular behavior. I got it to work once I understood this distinction.

    However big props should go to JJList for coming up with a "roll your own" solution to turret independent behavior. :)

    Thanks!

    Caleb

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