Get direction to a position?

Started by ByQ on

Topic category: Help with Minecraft modding (Java Edition)

Joined Feb 2026
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Get direction to a position?

So im trying to make a particle that moves to players position but i need the vx or vy direction but i dont know how to get it to a relevant position

is there a way to?

 

Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Maths. You get the x y z of…
Fri, 05/15/2026 - 22:30

Maths. You get the x y z of the particle and x y z of the player. The line joining these points is the exact line you want the particle to move. The vx vy vz are simply the components of that line, the vx being the velocity in the x direction. To get the vx vy vz, you do vx=x2-x1 vy=y2-y1 vz=z2-z1, the 2 being the destination coordinate and the 1 being the origin coordinate. To alter the actual speed the particle moves along that line, you simply multiply those vx vy vz by any value. ie work out vx which =  3, you don't want the particle to move at 3 blocks per second so you reduce it by shrinking the vector by a factor eg *0.1 = 0.3 blocks per second.