Hi poeple! This is my first threads so don't judge! <3 Anyway, I'm trying to create a spear. I have everything ready, only thing is that I want to make it move in a parabolic motion. If I could just set it's velocity, this wouldn't be a big deal, but since the spear is a location, I have to add the vector to the location. So I'm asking, how can I do this? Thanks in advance! - Finn

just keep adding the velocity to the location, and keep adding ? amount to the Y speed so it goes downwards faster and faster. or am I saying something st00pid now? xd

Thanks for the fast reply! I'm not sure if you know what a parabolic motion is (just wanna make sure you know though ) Anyway, just lowering the Y wouldn't look too good, and I know it's possible, so I'd prefer an actual parabolic motion.

I do know what a parabola is, but my solution would seem a lot easier xd Anyway, if you really want to go as realistic as possible: https://en.wikipedia.org/wiki/Projectile_motion

If you'd like some spoonfeeding, here: Spoiler: Spoonfeed Code (Text): public static Vector calculateVelocity(Vector from, Vector to, int heightGain) { // Gravity of a potion double gravity = 0.115; // Block locations int endGain = to.getBlockY() - from.getBlockY(); double horizDist = Math.sqrt(distanceSquared(from, to)); // Height gain int gain = heightGain; double maxGain = gain > (endGain + gain) ? gain : (endGain + gain); // Solve quadratic equation for velocity double a = -horizDist * horizDist / (4 * maxGain); double b = horizDist; double c = -endGain; double slope = -b / (2 * a) - Math.sqrt(b * b - 4 * a * c) / (2 * a); // Vertical velocity double vy = Math.sqrt(maxGain * gravity); // Horizontal velocity double vh = vy / slope; // Calculate horizontal direction int dx = to.getBlockX() - from.getBlockX(); int dz = to.getBlockZ() - from.getBlockZ(); double mag = Math.sqrt(dx * dx + dz * dz); double dirx = dx / mag; double dirz = dz / mag; // Horizontal velocity components double vx = vh * dirx; double vz = vh * dirz; return new Vector(vx, vy, vz); } private static double distanceSquared(Vector from, Vector to) { double dx = to.getBlockX() - from.getBlockX(); double dz = to.getBlockZ() - from.getBlockZ(); return dx * dx + dz * dz; } I googled "bukkit parabolic motion" and this was the first result, I also took the code from there. Enter the thread and look at the answers.

That is exactly why I said "I didn't write this code, I took it from a thread I found and enter it to read whatever they said"

I'm not saying you have made horrible code. And it might work, I don't know. But at least it could be so more simplified, variables could have a better name. A lot of things. I'm not judging you on anything, I was just pointing out that the code was horrible

What you could also do is create a discrete parabolic curve from short vector lengths, and have the spear follow their path. But that's probably overcomplicating things

Why not just create a parabolic function. Something like f(x) = -5x^2 + 5x + 10. Then use that to figure out the spears y value while incrementing the x and z based on the direction the player was looking. You then use the distance on the x and z planes for x in the function.

So, I tried some stuff and failed horribly. If anyone could help me with how I would implent this into a location, that would be great! (Basicly what I have to add to the location to make the parabolic motion!)

I love when your looking for information and you get to the bottom of a thread, it says "solved" but no resolution. If you still active you think you could post what you did?

Code (Text): public void progress() { this.x+=0.1; if(this.x > 10) { this.x = -10; } double y = 2 * (x * x) + 2 * x; Location loc1 = new Location(player.getWorld(), this.chest.getX() + x, this.chest.getY() + (y / 60), this.chest.getZ()); ParticleEffect.HAPPY_VILLAGER.display(loc1, 0F, 0F, 0F, 0F, 1); } chest is the player's location. I put that in a runnable and it did wonders