1.12.2 Parabolic Motion/Arc Velocity Calculation

Discussion in 'Spigot Plugin Development' started by SeanTMG, Apr 10, 2020.

  1. So I have a point 1, and a point 2, I need a player to ride an invisible arrow from point 1 to point 2 in an arc, I've tried the solutions of every thread I can find and none even remotely work.

    https://bukkit.org/threads/set-play...-parabolic-motion-to-another-location.327675/
    This thread sends the player to NaN, 0, NaN, getting them stuck in a kick loop for invalid packets

    I'm basically trying to recreate the portals in Hypixel SkyBlock. But I'm really not the best at math and Vector math gets really complicated. Any help would be appreciated!
     
  2. Depending on the exact behavior you want, you have two options here:
    A) Include gravitation in your calculation and literally "throw" the object / entity.
    B) Exclude gravitation and let the object / entity "ride" on a function graph per tick.

    Pro for A: You will only calculate everything once
    Con for A: You wouldn't be able to alter anything about the movement after throwing

    Pro for B: You can precisely control speed and even the movement pattern
    Con for B: You will update the velocity on every tick

    In either case, you would need a proper function to back it up.
    If you wanna try to figure something out yourself, I would recommend to take an (online) function plotter and visualize your function and how the different parameters effect the result. Just keep in mind, that depending on taking A or B, you would have to include gravity. Also functions are generally 2D, and this would need to apply in 3D space, so the third dimension also needs to be handled.

    Otherwise, if you have no idea what to do, just say what implementation you prefer and we could give you something to start with :)
     
    • Agree Agree x 1
  3. About these motion curves... You’ll need to supply more information:
    F = m * a = m * x’’ = - g * m,
    Which result in x’’ = -g.
    Solving w.r.t time yields the velocity
    v = - g * t + v0, resp. the location
    x = -0.5 * g * t^2 + v0 * t + x0
    The latter formula is what you would think of as “Parabola”. But if you want to plug that into something, you’ll need to think about boundary conditions; what should the starting velocity be; should the curve be passed through in a certain amount of time? Should the gravity be the same as the one MC has?
    Also, note that all letters written in bold are vectors.