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

Get help using Construct 2

Post » Sat Aug 30, 2014 3:40 pm

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.
https://www.dropbox.com/s/48mj5a5o677lw ... .capx?dl=0

Thank you.
B
45
S
23
G
31
Posts: 693
Reputation: 20,612

Post » Sat Aug 30, 2014 6:02 pm

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)
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Aug 31, 2014 6:22 am

@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.
B
45
S
23
G
31
Posts: 693
Reputation: 20,612

Post » Sun Aug 31, 2014 7:36 am

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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Aug 31, 2014 8:21 am

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:
Code: Select all
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)


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:
https://dl.dropboxusercontent.com/u/542 ... nPush.capx
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:
viewtopic.php?f=147&t=103339&p=775018&hilit=wall+sliding#p775018
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.
B
92
S
32
G
107
Posts: 5,280
Reputation: 69,971

Post » Sun Aug 31, 2014 8:43 am

@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!
B
45
S
23
G
31
Posts: 693
Reputation: 20,612


Return to How do I....?

Who is online

Users browsing this forum: atmas, Bootfit, Freak Workshop and 28 guests