Throwing Items in an Arc

Posted:
Mon Aug 08, 2016 22:20
by BrandonReese
I want to be able to send entities through the air in from position A to position B in an arc. Like throwing a ball. I can make entities go in an arc but I can't accurately hit point B. It would be nice to have a function that you could input two positions and it would return the values you would need to use in setvelocity and setacceleration to make the entity go from pos A to pos B in a parabolic arc (I think that's the correct term). If a function like this already exists in minetest let me know. I looked up the math and it was over my head. Thanks.
Re: Throwing Items in an Arc

Posted:
Tue Aug 09, 2016 01:20
by Byakuren
If you can choose both velocity and acceleration, there are infinitely many correct answers. Even for each acceleration, there are an infinite number of velocities that would work. I think that if you have both an acceleration, and desired travel time, though, you will have only one velocity that works. Other things to consider are whether you want your velocities to have a fixed magnitude.
Also, any values calculated this way are likely to not work out quite right over long distances or high accelerations, because Minetest uses the Euler method for movement calculations, which introduces large errors, including for constant accelerations. If you really want to do this, you should do your own position calculation and use setvelocity/setacceleration only for the purpose of client-side prediction.
Re: Throwing Items in an Arc

Posted:
Tue Aug 09, 2016 01:40
by BrandonReese
I guess it would be fixed acceleration and pass the position and angle to the function and it would return the velocity.