How would I go around implementing a top-down point and click grenade (arc throw)?
The player chooses how far they want to throw the grenade (usually based on their mouse location), and the velocity changes accordingly to ensure that distance is reached.
I have tried thinking of a way but can’t seem to figure it out.
The current system I have right now is that a baseline distance has a given forward and up velocity.
Just before throwing, I divide the current distance the player wants by the baseline distance, then multiply this value with the baseline velocity.
curDis = 4m baseDis = 7m baseForwardVel = 7.5m/s baseUpVel = 4m/s multiplier = curDis / baseDis // .57 forwardVel = baseForwardVel * multiplier // 4.275 upVel = baseUpVel * multiplier // 2.28 velocity = playerForward * forwardVel + playerUp * upVel
This system works but is somewhat inaccurate. At shorter distances, the grenade lands shorter than expected, and vice versa.
The only other solution I can think of is making a Vector Curve that consists of samples I have recorded myself (let’s say every 1 metre). However, I do not wish to use something that is so manual and time-consuming. For example, if I were to change the velocity, I would have to record all the samples in the Curve again. Even then, this solution still won’t be entirely accurate, just more accurate than the current solution.