Cesar1 wrote:Hello I would like to know how can I create radial gravity , a character moving around a planet
This is an interesting question! You could rotate character around a planet by simply changing the pivot point of rotation (point around which the object rotates), so instead of it rotating around its center, it would rotate around the center of the planet.
To do this, follow this thread info: viewtopic.php?f=19&t=8841
How to simulate a fully switched gravity (so you can add jump, etc) I'm not sure yet, as I haven't done this in Gdevelop. Some engines offer to change the source position of gravity.
Edit: There are "gravity coordinates" in Gdevelop, but I am not sure this is what I mean, I think it is something else.
If you check the description: http://www.wiki.compilgames.net/doku.ph ... lt_physics
It says gravity vector. A vector is basically the direction + intensity towards which the object will move. So, to make the object rotate around another object, you would need to constantly change this vector towards the center of the sphere object (e.g. when sphere is left from the object, it would be -1 0, when sphere is right from the object, it would be 1 0). Someone correct me if I misunderstood this and gravity coordinates are actually the location of gravity source. The following may not work, is completely theoretical and untested. The vector could be calculated using something like: atan2(Sphere.PointY(Centre)-Player.PointY(Centre),Sphere.PointX(Centre)-Player.PointY(Centre)) to get the angle between player and center of sphere, then using sin and cos to get the displacement (position change) vector toward that object. That would mean that movement vector should be something like
You may need to write Y: -sin(Variable(Result))*GravityStrength because positive sin is for when Y is going up. I think Y goes down in gdevelop, so this may be needed to be inverted.
Variable result would be the result of atan2 calculation, you would save it as the value of that variable, to avoid repeating calculation or very long lines.
There might be a simpler way, but basically you would need to use physics of some type (either built in forces or physics extension), and make sure to always have a kind of "magnetic" force towards the center of the planet. Untested, but maybe "Add a force to move toward a position" with value of centre point of the sphere object, or simply add a force to move toward an object (this may use centre point already, but I'm not 100% sure).