Finding the position directly behind a player

  • Context: Undergrad 
  • Thread starter Thread starter wolfknight
  • Start date Start date
  • Tags Tags
    Position
Click For Summary

Discussion Overview

The discussion revolves around using trigonometry to determine the position directly behind another player in the game Minecraft. Participants explore mathematical concepts and coding techniques related to player orientation and positioning within the game environment.

Discussion Character

  • Exploratory
  • Technical explanation
  • Mathematical reasoning

Main Points Raised

  • One participant describes their attempt to use trigonometry to calculate a position behind another player, sharing their code and expressing a lack of understanding of the mathematical concepts involved.
  • Another participant questions the reference frame for "behind" and suggests understanding how Minecraft stores player orientation as a crucial first step for calculations.
  • A follow-up clarifies that "behind" refers to the direction the player is facing, indicating that the orientation parameters are essential for accurate positioning.
  • A later reply mentions a successful resolution to the problem, stating that they can now teleport behind other players after overcoming initial difficulties with Minecraft's rotation system.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the best approach to the problem, and there are indications of differing opinions on the clarity and effectiveness of Minecraft's orientation system.

Contextual Notes

There are unresolved aspects regarding the mathematical understanding of trigonometry and matrices, as well as the specifics of how Minecraft's player orientation is defined and utilized in calculations.

wolfknight
Messages
5
Reaction score
0
I'm attempting SCIENCE by using math that I have never used before, nor do I understand (despite reading numerous articles, watching all of the khanacademy videos, etc etc)

I'm attempting to use trig to locate a point directly behind another player in Minecraft.
I've read through these three pages:
http://stackoverflow.com/questions/...rotational-axis-and-a-direction-calculate-end
http://en.wikipedia.org/wiki/Spherical_coordinate_system#Cartesian_coordinates
http://www.opentk.com/node/2505

and have come up with this code:

Code:
double dEntityDistance = getPlayer().getDistanceToEntity(player);
		
double dNewX = /* The current player */getPlayer().posX  - dEntityDistance * Math.sin(Math.toRadians(/* The player we want the position behind */ player.rotationYaw % 360)) * Math.cos(Math.toRadians(-player.rotationPitch));

double dNewZ = getPlayer().posZ - dEntityDistance * Math.cos(Math.toRadians(player.rotationYaw % 360)) * Math.cos(Math.toRadians(-player.rotationPitch));

I know nothing about matrices (which some have suggested), nor do I know very much about trig. If anybody would be kind enough to explain a bit about those two subjects (or whichever one would help me with my problem), I would be very grateful.
 
Last edited by a moderator:
Physics news on Phys.org
Behind relative to what? The plane, or the direction the player is looking to?
As a first step: Do you understand how Minecraft stores the orientation of the player? The definition of those parameters should give you a direct way to calculate x,y,z in front of the player. Behind is just the same, but with opposite signs for the distance.

Comments directly in formulas? Really?
 
mfb said:
the direction the player is looking to?
The direction the player is facing, yes, I apologize for not clarifying.

mfb said:
As a first step: Do you understand how Minecraft stores the orientation of the player?
I've been trying to find out for the last couple days. Notch and Jeb do it in a really really bad way, which is why I've been having loads of trouble.

mfb said:
Comments directly in formulas? Really?
Actually no, it's just that I was clarifying which entity was which.
 
I fixed this. Minecraft rotations are completely back-asswards, and it took me a while, but I now can successfully teleport behind other players.
 

Similar threads

  • · Replies 7 ·
Replies
7
Views
3K