# How to create a mathematical formula of circular / spiral motion with fixed distance?

I’m on a journey for days, and this may be my last attempt to solve it. First, I wanted to let you know that this is my first post in the community, so if I’ve got something wrong, please let me know.

I also searched for an answer here, and all I could find were other methods, using invisible objects in a way I’d like to avoid if possible.

I’m trying to develop a formula that allows me to move one or more projectiles, from the player, where the curvature angle value can be defined (examples: 0, -20°, 180°) and the time it stays alive in the scene is also predefined (examples: 500ms, 2000ms), however, the final distance it reaches must always be the same, regardless of the previous variables.

In this case, a gain in velocity would be necessary to compensate for the curvature of the projectile (in case of angle 0, I believe it would not be necessary)

It’s also relevant to me that the sync is with time, so I’m trying to multiply the parameters by a timer, instead of letting them add up frame by frame.

What I came closest to here, with a lot of trial and error and a few requests to GPT Chat for help, is what can be seen in the screenshots.

• “definir como” is “define as” or “=”

If the spin angle applied per second is 360 it dies at something close to twice the distance, if it is 360/256 (i.e. 1.40625 degrees) the projectile dies at the right time (but it’s such a small number, that maybe any Something close would give a similar result). Even so, it seems that there is a logic there, just missing “the final adjustment”. Just for reference the total time of this test circle is 6.4 seconds and the initial offset is 12.5 px per second. “tCircleLife” is a timer that activates with the start of the event and dies when it ends.

TL;DR

``````((Variable(vCircleFinalDistance)/Variable(vCircleLifeTime)*tan(ToRad(Variable(vCircleAngleAdctiveCompound)))))
``````

What do I need to do in this formula, so that this acceleration addition variable compensates for the “loss of distance” caused by the object’s angulation? (Compared to an object in a straight line with the same speed and created at the same time)

Since the result of this formula will be multiplied by a timer and added to the original speed of the projectile moved by force.

I thank everyone’s attention

IDK if this will help. But it reminded me of an old project that draws a quadratic curve and also calculates a point on it. The drawing part is separate and not needed. My thought is the objects could be replaced with values (or kept and hidden) You could change the height of the curve by changing the control point Y value. Do with it what you wish.

Try it: the points are all draggable. The slider goes from 0 to 100 but the value is converted to 0 to 1.

project:

1 Like

Man this is so beautiful working! But when I look at the formula I am almost completely lost. I really appreciate sharing this example, but at my current level, I can’t abstract it and adapt it to my situation.

For example, adapt absolute motion (x,y) to motion using forces.

But I confess that this example of yours makes me want to create a new project with a completely different gamedesign hahaha

1 Like

I don’t always understand why the various formulas work but I understand how to make them work in Gdevelop. If that makes sense. As far as doing it with forces, I can’t help you with that.

1 Like