Throwing Items in an Arc

User avatar
BrandonReese
Member
 
Posts: 836
Joined: Wed Sep 12, 2012 00:44
GitHub: bremaweb
IRC: BrandonReese
In-game: BrandonReese

Throwing Items in an Arc

by BrandonReese » Mon Aug 08, 2016 22:20

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.
 

Byakuren
Member
 
Posts: 441
Joined: Tue Apr 14, 2015 01:59
GitHub: raymoo
IRC: Hijiri

Re: Throwing Items in an Arc

by Byakuren » Tue Aug 09, 2016 01:20

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.
Every time a mod API is left undocumented, a koala dies.
 

User avatar
BrandonReese
Member
 
Posts: 836
Joined: Wed Sep 12, 2012 00:44
GitHub: bremaweb
IRC: BrandonReese
In-game: BrandonReese

Re: Throwing Items in an Arc

by BrandonReese » Tue Aug 09, 2016 01:40

I guess it would be fixed acceleration and pass the position and angle to the function and it would return the velocity.
 


Return to Modding Discussion

Who is online

Users browsing this forum: Google [Bot] and 3 guests

cron