Simulate bomb throwing in top down game.

0 favourites
  • 6 posts
From the Asset Store
Throw daggers and hit the most fruit! Watch out for the wind, if you run out of daggers you'll lose the game!
  • Hi all,

    I am trying to simulate a bomb throw similar to how link does it in link to the past. Right now, I have the bomb being created at an imagepoint on the player. This sets a boolean to true will the bomb is active. I am also setting the position to this same imagepoint every tick while true. I have the throw button setting the boolean to false and its dropping the bomb at that point. This all works great. I need to now actually add some force to throw the bomb in the direction that the player is facing. I would also like the bomb to bounce a bit when it lands. I am not sure what behavior I should be using for this and how to simulate the bounce given its a top down game. Any ideas will help. Thanks!

  • I guess you will have to use scale. set a variable called zscale set it at 1 and set scale of your bomb to that. When you throw it up scale will increase, then after a certain point start to decrease ( use gravity variable set at something like 0.02 )

    So it would look something like this ( you will have to change numbers until it looks right, I have not actually tried it in a top down game )

    After bomb thrown set power to 0.1

    zscale = zscale+power

    power = power - gravity

    bomb set scale to zscale

    Set limits so when zscale gets to 0.5 or wherever you want ground to be it bounces back by

    if zscale<zscaleminimum power = power*-0.9

    For direction of throw use angle of throw to set x and y direction. Similarly set xspeed and yspeed to increase like zscale and instead of gravity slow it down via drag variable, or something like that

  • Nice, I will give this a go and let you know how it turns out. Thanks!

  • There's lots of ways to do this. One way I like to do this is with Tween

    Here's an example if you're throwing it to the left

    tween "x" to self.x - 200 over 2 secs (linear)

    tween "y" to self.y - 100 over 1 sec (out sinusoidal)

    wait 1 sec

    tween "y" to self.y + 100 over 1 sec (in sinusoidal)

    the out sinusoidal followed by the in sinusoidal will give it a nice arc that looks like gravity

    you can tweak these values until it feels right

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I have this working with tweening but i need to account for collisions. Im doing this in C2 with LiteTween. How would account if the bomb hits a wall to stop the tween?

  • You could do

    On collision with wall

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