Ignore Gravity

Get help using Construct 2

Post » Sun Jan 06, 2013 11:22 pm

I want some elements to be affected by gravity and others not to be.

At the moment I am trying to fake gravity by applying a downwards force every tick for the appropriate objects but this is causing some problems. Is there a better way to do this?

Cheers,
Mick
B
39
S
12
G
8
Posts: 580
Reputation: 7,108

Post » Mon Jan 07, 2013 1:41 am

Are you using physics or..?

If you post a capx, it'd help us understand the problem better.
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Mon Jan 07, 2013 6:20 am

I was trying this also. Using the physics plugin it seems you can set individual gravity. Though after having used Box2D I thought you could :|
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Mon Jan 07, 2013 11:24 am

Sorry I can't post a cap it's in a massive project :(

But yeah I'm using physics, world gravity is set to 0 and for each object which I want to be affected by gravity I am applying downwards force to it. It sort of works but when I stack objects or move them around they start to shake and stutter.
B
39
S
12
G
8
Posts: 580
Reputation: 7,108

Post » Mon Jan 07, 2013 3:15 pm

Ah just tried it. Yeah you're right, it doesn't work.

What about the setting the Y velocity? I set it to -8.3 and it's so slow it's not noticable.

Sprite Set Velocity to (Sprite.Physics.VelocityX, -8.3)

Works nice in my little tester. Don't know if that kind of hack helps in your situation though. But it does stop the shaking.

Then when you want gravity back, don't execute that event.
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Mon Jan 07, 2013 4:23 pm

yeah it is smoother but brings up further problems. Does anyone know how the gravity works in code and if there's a way to reproduce this through events?
B
39
S
12
G
8
Posts: 580
Reputation: 7,108

Post » Mon Jan 07, 2013 5:19 pm

To keep it working with physics, set velocity is your only way really, apart from apply force which you've tried.

Sprite Set Velocity to (Sprite.Physics.VelocityX, 9.1) would apply gravity.

Gravity with events is essentially the same as set velocity, except physics would be messed up (collisions and whatnot).
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Mon Jan 07, 2013 9:05 pm

Hello Mick,

Just a thought here, but maybe you could use your current system with some modifications. Maybe stop the downward force when the object collides with another object and apply it only when there is no collision? Or scale the amount of force relative to the object's distance from another object?

I just started playing with the Physics stuff, so sorry I can't offer specific ideas related to that!
B
16
S
6
G
2
Posts: 152
Reputation: 3,764


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 0 guests