Gravity direction

Get help using Construct 2

Post » Thu Mar 01, 2012 10:19 pm

Hey there,
In the physics behavior, gravity direction points to the bottom of the page. Would it be possible to update this behavior and ad a function allowing the gravity direction and stength to change according device inclination ?
I'm sure that's a behavior many people would love to have.
L

B
21
S
9
G
4
Posts: 197
Reputation: 4,105

Post » Thu Mar 01, 2012 10:50 pm

You can already do it yourself.

Set the gravity to 0, and every tick add a force on your object.
The angle/direction of this force depends on what you want, and this is a way to apply gravity in the direction you want.

It requires a bit of math I guess, to transform the orientation into an angle for the force, but it is doable.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Thu Mar 01, 2012 11:03 pm

Oh, Thanks Kyatric. But that's why I was longing for a great all-in-one behavior, because I'm really not used to maths and I don't know how to grab information from the tablet gyroscope.
B
21
S
9
G
4
Posts: 197
Reputation: 4,105

Post » Thu Mar 01, 2012 11:12 pm

Just to add:
the force has to be multiplied by object.physics.mass too


0.2 * object.physics.mass is the rough equivalent to the default gravity (which is a value of 10 for some reason)
B
28
S
8
G
1
Posts: 469
Reputation: 4,683

Post » Thu Mar 01, 2012 11:23 pm

Thanks, Keepee. And how do I get the inclination from the device sensors ?
B
21
S
9
G
4
Posts: 197
Reputation: 4,105


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 29 guests