Solved Calculating an armorstand head rotation

Discussion in 'Spigot Plugin Development' started by mindgamesnl, May 27, 2017.

Thread Status:
Not open for further replies.
  1. Heyall!

    I currently have a plugin that does fancy stuff with armorstands but im stuck at one point.

    I want a armorstand to look at a certain block (Location) by setting it's pitch and yaw but how do i go about calculating it?

    Thanks all :3

  2. Code (Java):
    Vector one =  /* location one */; //origin
    Vector two = /* location two */; //target
    Vector direction = two.subtract(one);
    //use #setDirection on a location object with newly calc'd vector
    Check the javadocs for Location and Vector, you can see the methods for them.
    • Winner Winner x 1
  3. YES!

    Thats it!

    Thank you so much :3
  4. Turns out, vectors don't store pitch and yaw
  5. it does . You can just rotate the armorstand by get it's location , set director to that vector , then if you need pitch and yaw , you can easily get it from the location
  6. Right, which is why you calculate a directional vector (from the two location vectors). Then you apply that to Location#setDirection.
  7. Neat! thanks :)
Thread Status:
Not open for further replies.