I cannot make these two different bullets behave the same !!

0 favourites
  • 6 posts
From the Asset Store
Adjusting the game screen for different resolutions (Letterbox scale)
  • Good day gentlemen,

    Here is my problem. I am (still) doing a tower defense game, and currently I am programming bullet behaviors.

    I already made my first turret shoot bullets and make the bullet subtract the correct amount of life off the enemies, but now I made a second tower, a rocket tower, but whose logic is exactly the same : it shoots bullets (rockets), and when bullets hits enemies, I want them to deal the appropriate damage, and then be destroyed.

    I literally copy/pasted the events from the first working tower to my rocket tower, and this is what happens :

    -on collision with enemies, rockets do not deal any damage

    -on collision with enemies, rockets do not become invisible, nor they are being destroyed.

    (BTW : the reason for making bullets invisible is because they would deal damage to all enemies hit at the same time instead of just one enemy, and I have been told on this very forum asking the program to make the bullet invisible would correct that, and it does. Nothing unusual here.)

    I simply don't understand whats wrong with my logic, so here I am, asking help on the forum.

    Hopefully someone will be able to help me. Thank you !

    here is a print screen of the events in question. If you need the actual game file, let me know.

  • DiabloOvermind

    Are the (Rocket_Projectile.UID) and (Towers) the same object??

    If not How do you link them?? I refer to the event 7 because the Rocket_Projectile when are created can have different UID unless you link them somewhere else that's the only thing I can see that doesn't make sense

    I see that in event 3 you pick up the instance variable from the bullet but on the Event 7 you pick up the UID of the Rocket_Projectile.UID which is a completely different thing, I think you meant to pick the Rocket_Projectile.(Instance Variable) and you picked up the UID by mistake

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • tarek2 is right, you typed .UID instead of .Parent_UID

    DiabloOvermind, Here is a little advice on how to deal with such issues.

    In my project I added a text object called Debug to all my layouts. Every time something doesn't work as expected, I write debug information into this text field, and this has helped me a thousand times!

    In your case I would do this:

    Rocket on collision with Enemies  -> Debug Append text " R:" & Rocket.pickedCount & " E:" & Enemies.pickedCount
       Towers pick instance with UID.... -> Debug Append text " T:" & Towers.pickedCount
       Else  Debug Append text " T:0"
    [/code:7vsf3h73]
    
    Your debug text will look like this: [i]R:1 E:1 T:0[/i]
    You'd know exactly where the problem is and will be very easy to find the mistake.
    
    This debug trick can also reveal some obscure problems, which you wouldn't notice without it.
    For example, what if collision happens with 2 enemies at once? In your Debug output you'll see [i]E:2[/i] and understand that you should probably add For Each Enemies loop to your code.
  • tarek2

    Thank you very much. Now that you pointed it out to me, it looks incredibly obvious, and I look incredibly stupid. But that's part of the learning process, I guess !

    The issue has been corrected from Rocket_Projectile.UID into Rocket_Projectile.Parent_UID (which is a variable, and not the object's UID indeed) and things works as intended.

    Thank you again, my good sir.

    dop2000

    I had to read that a couple of times before to understand exactly what you meant

    Surprisingly, I also help myself with text objects sometimes, when the step by step debug screen testing process isn't helping. I usually ask those texts to display variables, or whatever information I think is relevant. At first, I thought there was an object called debug, and that this would find every little bug in my program, but once I read you again I understood that was not the case, a shame thought ! But then programming would be too easy

    However, how can this debug text object could help you find problems if you do not ask it to display specific information beforehand ? Or did you mean it helps you find additional bugs while you are searching for other bugs ?

    Anyway, that's a great advice, thank you very much !

    P.S : nice reverse twisted Tetris game you got there mate !

  • [quote:1evxtt32]However, how can this debug text object could help you find problems if you do not ask it to display specific information beforehand?

    What can I say? Sometimes this happens

    One example is in my previous comment. I often use Debug to display PickedCount of different objects and sometimes it shows a larger number than expected.

    Also, I always use "Debug -> append text". And sometimes when I think that some event should only be executed once and I'm debugging some unrelated issue and suddenly see this:

    "X:1 X:1 X:1 X:1 X:1 X:1 X:1 X:1 X:1 X:1 X:1 X:1 X:1 X:1 X:1 X:1 X:1 X:1 X:1 X:1 X:1 X:1 X:1"

    This makes me realize that I forgot to add "Trigger once" condition.

    [quote:1evxtt32]P.S : nice reverse twisted Tetris game you got there mate !

    Thanks! Doptrix was my first game, I had zero experience when I started making it. And I'm really proud with the result.

    I hope my new game will be even better

  • DiabloOvermind

    No problem mate glad to help, don't worry it happens to everyone, to be honest, it wasn't easy to spot I had to read it a few times myself

    dop2000 give you a really good advice and very important one, it will make your life easier Debugging things

    Btw dop2000 Nice addicting game congrats

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