# Help needed

Hi nya. Soo, I’m learning how to use GDevelop by copying the first level of a Snes Castelvania. I need help with something:

When Belmont goes within a certain distance of the skeleton, the skeleton changes to the “throw” animation and creates a “bone” object in the hand of the skeleton. I need to know how to program that bone to make a parable aimed to my hero’s position at the time of the bone item creation nya.

Thank you nya!

Ok, this one is interesting, I had some free time so I tried some old school physics maths:

I have solved it for two logic ways:

• You can give the speed in the Y axis (how high you launch the bone), then the speed in the X axis (and the angle) is calculated to make the bone reach the target.
• You can give the angle, then both speeds are calculated, this one is a little tricky so I added some restrictions.

Check the example:
Parabola.zip (3.7 KB)
You can de/activate both methods with the two events that have the condition “At the beginning of the scene”, the variable values are:

• The gravity “g”: It determines how fast the bone will fall, if the gravity is very high the y speed will be increased very fast, so you force the x speed to be very high too, to reach the target, then the gravity could be read as projectile speed.
• For the first system, the initial speed on Y “voy”: Of course it has to be negative if you want to throw the bone up.
• For the second system, the initial angle “angle”: It is always positive, you can throw the bone up only.

The problem is that I don’t know right now how to use the GD bultin forces to simulate the gravity, I used the classic: Position = Position + Velocity * DeltaTime, Velocity = Velocity + Acceleration * DeltaTime.

That’s amazing, nya xD It worked perfectly. I just have to adjust the speed a little bit nya. Man, that math looked pretty smart. I didn’t get any of it, though, like, nothing, not a little bit, kinda stupid I am, so thanks for taking your time to help me, I really appreciate it nya ^^. You should add it to your tutorials, like, “Parabola projectile” or something like that, in case someone else needs it.

Thanks a lot, nya♥!!!

I don’t think so, it’s some projectile equations + Bhaskara to solve it, maybe you have never studied these topics or didn’t pay attention

Don’t worry, if somebody need it I will remember it’s here… nya? haha

I couldn’t follow all the maths either, but I did come up with a simpler way of doing almost the same thing.

I made the target red square draggable and put the throwing/firing on a timer, so you can see how the angle of the parabola changes as the “player” moves.

Lizard’s solution is far better and works wherever the target is on the screen, whereas mine stops being accurate as soon as the Y position of the target changes, but as a quick hack it’s not bad.
Parabola-simple.zip (2.8 KB)

Thanks!, the more examples the better. I have a little problem about over-complexing everything, I don’t know why. If I can make a more general solution I have to do it even if the result is not nice at all

Sometimes a quick approximation will do, but I think everyone would like to see the clever, complex solutions because it shows more of what GDevelop is capable of. The current wiki doesn’t really say much about the mathematical functions so it’s only from examples that you and others provide that I can start to work out how they can be used.

Jaja, I don’t think “over-complexing” is a problem, but rather a rare and very practical quality nya. Complex answers are usually more useful in the long term that more simple ones, but simple or complex answers are both valid as long as they solve the problem at hand. And keeping in mind that the people who seek to use GDevelop as an engine, like mua, do it because is simple to use and simple minds always come up with simple answers, guys who think the hard complex answer are appreciated. So than to both of you nya.

I tried Mat’s example and it’s actually pretty good as long as I’m standing always on the left of the target and bellow his Y axis coordinates. It would be perfect for a cannon fixed to a wall firing bullets at the character, so it’s neat. Lizard’s code worked for every position, except for when my character was standing in a higher Y coordinate that the skeleton, but I modified it and it worked perfectly. You both are great, nya

That each one have a parabola effect and be independent
How to solve this?