#How to track arrow position in minecraft for graphing as quadratic function (without drag)?
1 messages · Page 1 of 1 (latest)
not really, but i assume its quite counterintuitive. I guess the easiest way to do it would be to just run the "tracker" on repeat through the whole motion.. not really sure how to do that tho
nah it's not counterintuitive dw
tl;dr is
thing happens in game (someone shoots a bow) -> server fires event (ProjectileLaunchEvent) -> anything set up to listen for ProjectileLaunchEvent runs the relevant code in an event handler
it's like if you fire a gun in a suburban area the police show up
are you trying to get the real trajectory of the arrow or just convert its launch velocity and angle to an equation?
er, by real i mean
if it hits a block midway, though that wouldn't fundamentally change the equation that maps its position
the issue is i need all (at least the max and zero points) to be able to graph it as cuadratic
if you're only trying to do the latter, then you don't need to track its position at all
oh true
id be doing it on a superflat anyways
aye
its for a math project
okay that clears things up lmao
uh
thinking
so basically you need to have the equation in X/Y/Z
yeah
you can decompose it to a linear system
id do only x and y or z and y
since all 3 components are independent of one another, I mean
shooting the arrow as if it was a 2d plane as to9 not overcomplicate
(straight liine not diagonal within the x/z axis)
Since drag doesn't matter, your X and Z won't really be all that important here
wdym
like
Sorry I should clarify - your X and Z velocities will remain constant, so you really only need to worry about your Y velocity
since gravity
tl;dr you can do this without needing to track the arrow, i'd argue trying to generate a best fit parabola for a set of points would actually be harder lol
bc im just graphing the position\
especially with a low tickrate
hmm
well, you can do two things
fair poinmt
- obtain parameterized launch velocity in terms of time t with respect to x/y/z (i phrased this badly)
- use a timer to find the real time in flight for any given arrow
You actually don't even have to do that much trig here, velocity is stored as a 3d vector on entities so you don't even have to worry about converting the direction vector
yes
...that wouldn't be that hard either, come to think of it LOL i think this is entirely trig-agnostic since rotation/etc. is handled already
yeah true
yes i think it is
again i think its even simpler given that i only need the arrow's position
yeah
and just feed the time into the equation you have
so like if the arrow starts out with a velocity of 10, 10, 10 and is in flight for 20 ticks (1 second)
i see what you mean
you'd just do 10 * 20 for both x/z
and then for y you'd want to factor in acceleration, which is just 1m/t^2
however i dont have an equation yet
for the parabola
id probably get that from the actual position
well the launch position can tell you everything you need to know
true
since that'll tell you what the x/y/z offsets are for one point on the parabola
my main concern with tracking its position is gonna be
minecraft servers run at 20 ticks per second
it's very likely you'll miss the actual maximum of the parabola
like it'd be simpler to track the arrow's position, sure
but like for an arrow where you launch it at a relatively gentle angle, it'll pass the maximum at considerable speed
this may help you
this is like, physics 101
kinematics
ye ye im in physics HL
vf = final velocity
vi = initial velocity
delta x = change in position on that axis
a = acceleration
however
if the arrow only moves in each tick, wouldnt it reach the maximum during a tick?
depends on how the server handles things
see
the server only updates during a tick
a good way to showcase what i'm talking about is uh
make an arrow tracker and have it just spawn a particle at the arrow's location every tick
you'll see how jank it is
but you as the player will see the arrow moving smoothly
that's because the game interpolates the arrow's location in the render loop
true
otherwise you'd have every arrow moving at 20 fps
it'd look like shit
not just arrows -every entity
yeah i see what you mean
so ig its more convenient to go for the velocity approach?
as the slope in the quadratic function x over y is going to be v anyways
quadratics don't have a slope, wym
i mean
they have tangents
like slope at a specific given point
thats what i menat
wait what level of maths is this
okay so there's no calculus involved here
nono
was gonna say if you wanted the arrow's velocity at any given point, velocity is a derivative of position and you could just write something really basic to derive it for the y component but that's outside the scope of this project
yeah
so yeah for the core of what you're doing here
however for that youd still need the position no?
anyway, fundamentally you just want to grab the initial launch velocity and use that to determine the arrow's position at any given time t
i like this idea, so id just base it on the initial speed
i know how the speed is going to change given mcs gravity
assuming it is vertical speed not horizontal
use that and initial position to get the position at time t
then i can probably js graph x/t
do you know where exactly the arrow is shot from? is it from the block on player's head?
anyways, thank you very much for the help. I'll let you know how it goes. Cya!
How to track arrow position in minecraft for graphing as quadratic function (without drag)?
public class Trajectory {
private float vx, vy, vz;
static final float GRAVITY = -1.0f; // not where i'd put this, but for the sake of example
public Trajectory(float vx, float vy, float vz) {
this.vx = vx;
this.vy = vy;
this.vz = vz;
}
// returns the arrow's change in position t ticks after launch
public Vector evaluate(float t) {
// very simple since you don't have anything acting on vx/vz
float dx = vx * t;
float dz = vz * t;
float dy = vy * t + 0.5f * GRAVITY * t * t;
return new Vector(dx, dy, dz);
}
}```
something like that
sorry i was afk
uh, you can get the arrow location in ProjectileLaunchEvent
Ok
How do i run this as a plugin?
I tried using eclipse with a code by chatgpt and just couldnt get it to work
Apparently eclipse wasnt recognising my spigot 1.17 jar file so it kept showing errors
I js need a way to implement it in mc
that's just a class to store the information
how new to programming are you?
don't do this
chatgpt is shit
you will not learn by using it
Very
ðŸ˜
How could i add the projectilelaunchevent detection to the game (just to get that initial position then its all math) to run it on a server?