# Solved Is it possible to make a function like this?

Discussion in 'Plugin Development' started by sohardhun15, Aug 13, 2016.

Not open for further replies.
1. Offline

### Forge_User_04597241

Hi,
Im working on a Player Launcher plugin and i'm wondering, is it possible to shoot a player from A to B? (A and B are specified for every plate) I tried plenty of function that counts velocity, but they are unaccurate.

2. Offline

### I Al Istannen

@sohardhun15
Possible? Yes.
Feasible? Depends.

If you want to set the velocity once:
You will need to account for minecrafts gravity, somewhere defined in the source code.
You need to stop the player from moving at all.
Then you may need to correct the course mid air, to land them exactly on the location.

If you are okay with modifying it during flight time:
You are probably better of making a direct parabolic courve and adjusting the player velocity to follow it.
So you ignore all the gravity and stuff, you just need to model the arc.
There are probably functions for that on the internet

And you need to make sure the path is clear, or the player will experience kinetic energy xD

Haven't tried any of this, just a quick thought.

EDIT:
For the curve a simple sinus could be enough:
x ::= The distance to the block you want to land on
t ::= The increasing parameter of the sinus (otherwise it would be a line)
f (x) = sin( ( π / x) * t)

Then you need to rotate that to allow throwing in not only the 4 "straight" directions (-x, x, -z, z) and some handling for y difference. No idea on the last point.

Last edited: Aug 13, 2016
#2