###

» Fri Jul 21, 2017 3:14 pm

Set gravity to 'zero', be aware that if you do that for 1 object, you do it for all. There is no concept as a 'personal' gravity in c2.

That is why you have to do this with an action, so you can not set gravity to zero by accident. The action is under (any) object with physics attached, under Physics > global settings > Set world gravity.

Now, just 'Apply force towards position' with x = object.X + 200 and Y = object.Y

Or. 'Apply force at angle' with angle = zero or 180

Be aware that a force is applied 'every tick' and an impulse is applied 'only once'.

Now you have a horizontal floating object.

If you need gravity. Then you have to counter the force of gravity. Gravity is applied 'every moment', under a 90 degrees angle. If keeping the defaults it is 10 m/s^2. That is just close to Earths gravity 9.80665 m/s^2.

Just as in the real world, to fly we need to apply a force, and in the opposite direction of gravity.

Just as in the real world, objects fall at the same speed, no matter its mass.

But, when we apply a force, the effect of that force depends on the mass of the object. How more mass the object as, how more force we need to move it the same distance.

In the real world, the force that we need to apply is just its weight. Weight = Mass * Gravity.

To do that in C2 we meet 2 problems. Its mass calculation has a conversion problem build in. And physics divides time in pieces of length 1/60 (in its default state), not in length dt (1 tick).

So lets make this story shorter, save you the math, and kill time and conversion problems.

'Apply force at angle' with ....

angle = 270

Force = (Sprite.Physics.Mass ) * (1/60) * (gravity + (gravity/5))

gravity = the number that you used with the action 'Set world gravity'