How do I make a smooth balloon movement in this scenario?

0 favourites
  • 6 posts
From the Asset Store
A Rise Up game clone. This is a template for your projects.
  • Hi everyone,

    I want to create a game where the player can rotate the entire screen. In it is a balloon with an obstacle course. The rotation isn't a problem, the problem is having the balloon move smoothly as if there is gravity. I tried using physics, but I can't find a way to change the direction of the gravity, so I used platform instead. It works to a certain degree. The problem is that if it is tilting slightly to one side, the balloon won't slide across it naturally. If it is in contact with a wall, it stops there instead of sliding to the end like a balloon would naturally do.

    I've included a capx so you can better understand what I am trying to do in case my explanation isn't that clear. ... .capx?dl=0

    Thank you.

  • Would using bullet behaviour with gravity enabled work?

    It has the bounce of solids feature, which could work well with balloons..

    Only thing you'd have to do is inverse the gravity..

    (Not sure if this can be achieved by using a negative number or if flipping/rotating the whole layout or layer would be required)

  • LittleStain, thanks for your advice. I tried using the bullet behaviour and I edited it. I saved the direction of the gravity in a variable and set it to the bullet angle, and did quite a few tests to see which had the smoothest results which works well to a certain extent. The biggest problem though with this is that I am getting collision counts in the mid 3000 to the high 4000. I am planning to have this game as a mobile game, so I am worried that this will have a huge impact on performance.

    Wonder what other methods I can do to keep the counts lower or newer approach I can take to solve this problem.

  • I guess a lot of the answer lies in optimizing..

    try to cut down as much as possible on the every tick events,

    set collisions disabled for all objects not having collision,

    if possible reduce the amount of points in the collision polygons..

    and such and cetera..

  • For the physics behavior you can do a custom gravity angle by applying a force at an angle to the balloon every tick. This is by far the simplest to do.

    The motion bit isn't hard you could even do it without behaviors with two variables VelocityX and velocityY and an event like:

    Every tick:
    ---add acceleration*dt*cos(degrees-90) to velocityX
    ---add acceleration*dt*sin(degrees-90) to velocityY
    --- ball set position to (self.x+velocityX*dt, self.y+velocityY*dt)[/code:34atxzhw]
    The collision response with wall sliding is trickier.  I'd recommend the custom movement behavior with the "push out nearest" action but I doesn't look right imo.  But pushing out the closest direction is what is required for sliding, well that and making the speed in direction of the wall zero.  For that you'd need two pieces of info: collision normal and overlap depth.  
    They possibly could be found with a bunch of is overlapping at offsets to find where around the ball is free and from that get the normal, then a few more overlap checks to get the overlap depth or just to push the ball out of the solid at an angle.  With 3000 collision counts per second that would be 50 per frame at 60fps.  You possibly could get it to work with using overlap checks in events but it would be tricky.  If all your walls are only rectangles you'd only need to check 4 directions (wall.angle, wall.angle+90, wall.angle+180 and wall.angle-90).
    Here is a capx of that idea:
    [url=] ... nPush.capx[/url]
    Notice it's a bit jittery so it may need some more finesse. Maybe a sub event of 10 to backup into the wall by smaller steps than a pixel.  As it stands I get about 10 collision checks per tick.  Also pushing out at the corners of walls will be jumpy.
    A superior method is in slide3.capx in this post:
    It does one overlap check per wall and then calculates the closest direction and how far exactly to push out.  The con is its much more complicated to make.  Also a bench would have to be done to see if it is actually fast or if the extra calculations counteract. 
    But again the physics behavior is the easiest to work with.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • LittleStain, yeah I tried to optimize it but I think it is kind of hard for my method, since to optimize it would mean to use the every x seconds instead of every tick. I tried every 0.05 seconds and the collision count is still high. And any higher and you can see the choppiness.

    R0J0hound, Wow thank you for that. I was looking for a way to control the gravity force for physics, so will definitely try this. Wow, your methods are not only effective, they are super efficient!! I am sure with a bit of work I will be able to smooth out the jittery a little, but it is definitely a good direction to go compared with mine. Wow, but the second superior method is super efficient and yet works like a smooth oil machine! Haha to be honest, I am very bad at maths, so I am getting a bit confused looking at your slide3 capx, but it is too good to not study it! I will try to understand it and how I can implement it into my game. Thank you so much!

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