Enemy Spawn Coin (action) When Destroyed.

Discussion in 'How Can I...?' started by volcank, Jan 15, 2017.

  1. volcank

    volcank Serious Boxer

    Joined:
    Oct 8, 2015
    Messages:
    794
    Likes Received:
    391
    Hi,

    I have a problem spawning coins when an enemy dies.

    What I did was. I created an object going from left to right and right to left and spawning bullets falling on the floor. Just like space invader, or Galaxian kind of. When the bullet hits the ground it is destroyed by the floor So floor is set to kill enemies. What I want is I want the bullets to spawn a coin when it is destroyed. How that is possible. I created a coin action. I even added that action inside the death of spawned bullet. Still doesn't work.

    Another thing I did was I even spawned another enemy so when it is destroyed it created a coin action to be picked up.

    What happens in the both situations above the coin keeps on falling down.

    I am sure there must be an easy way to do this but seems I can not solve it. I would really appreciate if anyone can help in this situation.
     
  2. Christoph

    Christoph Miniboss Boxer

    Joined:
    Oct 4, 2015
    Messages:
    2,807
    Likes Received:
    2,309
    I think the only way to do this is by hiding the coin behind the enemy. Not sure if it disappears when the enemy dies and it is connected to it. You have to try.
     
    volcank likes this.
  3. volcank

    volcank Serious Boxer

    Joined:
    Oct 8, 2015
    Messages:
    794
    Likes Received:
    391
    Yeah I trid it spawns the action also with the bullet but now it is destroyed when the bullet is destroyed.I also copied and pasted the action inside the defeated animation. (Like your tutorial which you earn points when you kill an enemy) but now the action keeps on falling down like there is no collision on the floor.
     
  4. meremy

    meremy Avid Boxer

    Joined:
    Aug 26, 2016
    Messages:
    134
    Likes Received:
    66
    volcank likes this.
  5. volcank

    volcank Serious Boxer

    Joined:
    Oct 8, 2015
    Messages:
    794
    Likes Received:
    391
  6. meremy

    meremy Avid Boxer

    Joined:
    Aug 26, 2016
    Messages:
    134
    Likes Received:
    66
    What I was able to do was this: The bullet has a death animation an OBJECT (enemy, with damage 0, Spawn Rate: 99999). So when the bullet hits the ground(character bullet with 999 life) the bullet will be destroyed and will let the object static in it's place. Now when the character (who has damage 1) touches the object it will automatically destroy it. And the coin is in the death animation of the spawned object :)

    Hopefully you understand :D if not i can send you the project. Currently i get +2 coins per bullet don't know why
     
    Christoph and volcank like this.
  7. meremy

    meremy Avid Boxer

    Joined:
    Aug 26, 2016
    Messages:
    134
    Likes Received:
    66
    It's Buildbox :D it can't be perfect :) i'm sure there are a lot of ways to fix this +1 coin :D
     
  8. meremy

    meremy Avid Boxer

    Joined:
    Aug 26, 2016
    Messages:
    134
    Likes Received:
    66
    Well that's just if you want the player to see and pick the coin up. There is no need to make its opacity 0. You put the coin in the death animation of the bullet and make it big enough so the character takes it automatically
     
  9. meremy

    meremy Avid Boxer

    Joined:
    Aug 26, 2016
    Messages:
    134
    Likes Received:
    66
    I've played a bit with it and sometimes it takes 1 and sometimes 2 if i make the action big enough. If i activate Debug Mode i can see that the spawner in the bullet creates some sort of collision box and i think that is the problem
     
  10. kodagames

    kodagames Avid Boxer

    Joined:
    Oct 11, 2015
    Messages:
    294
    Likes Received:
    115
    yep its creating 2 collision boxes and 2 coins. Good catch by the way! :D I wrote support and its been solved there are no longer duplicates.
     
    Last edited: Jan 16, 2017
  11. volcank

    volcank Serious Boxer

    Joined:
    Oct 8, 2015
    Messages:
    794
    Likes Received:
    391
    Hi I have done your way for my scoring purposes and actually didn't have good luck when tried for coins. But will try your way. By the way when I did for scoring I had the same problem. The way I chose it have set the action duration to 2 and the spawned action animation frames to 50. I guess scoring twice has got to do with how long that action stays on screen. Try to play with Action duration alone and the frame count of the spawned action. You do this inside the defeated animation where you paste the action.
     
  12. kodagames

    kodagames Avid Boxer

    Joined:
    Oct 11, 2015
    Messages:
    294
    Likes Received:
    115
    @volcank
    When you scale the coin up in the Defeated Animation to cover the player when activated and you have the animation frames set to a number say 90 it will stay there for that long. If you change the frames to 1 then when the coin is activated it will disappear immediately. I also noticed the same thing if the coin is there for example the 90 frames the character (player) will be in contact with it for that long and then the score increases (1,2,3..) for that duration.

    I haven't had luck with the action Duration using the copy paste method.

    I posted in the Feature request part of the forums for Objects to Use actions:
    https://www.buildbox.com/forum/index.php?threads/objects-use-actions.8769/
    +1 if you would like this?

    To me its getting old always hacking this and that to get something to work.

    I like the fact that the frames are in the Defeated Animation slot so that I can replace what was killed for a certain amount of time, in one game I had it set to like 500 frames because I wanted to keep it on screen (not a coin of course, but eye candy).
     
    Last edited: Jan 16, 2017
  13. kodagames

    kodagames Avid Boxer

    Joined:
    Oct 11, 2015
    Messages:
    294
    Likes Received:
    115
    @volcank
    I have uploaded a BB doc so you can see how it works :D
     

    Attached Files:

    volcank likes this.
  14. volcank

    volcank Serious Boxer

    Joined:
    Oct 8, 2015
    Messages:
    794
    Likes Received:
    391
    Thank you I also liked your other thread. I think it is a brilliant idea. Thank you for that. It's a shame that BB is so easy to use but we try to do other easy features with some other tricks. LOL. I mean some things in other game engines are so easy to do. I hope things will change through time.
     
  15. volcank

    volcank Serious Boxer

    Joined:
    Oct 8, 2015
    Messages:
    794
    Likes Received:
    391
    Cool Works Great! I really wonder if we can also spawn another enemy that we killed. So when we kill one another appears with the same properties. And even maybe 2 of them are spawned. I am planning to make a shooter which when the enemy is killed another harder one is spawned.
     
    playsgames6666 likes this.
  16. meremy

    meremy Avid Boxer

    Joined:
    Aug 26, 2016
    Messages:
    134
    Likes Received:
    66
    That might be possible :D but you can't have the same enemy because that will create a loop.
     

Share This Page