Jump to content

Recommended Posts

Posted

I am trying to make an entity look at another entity but I can't seem to get the math working. My current code is basically a copy-paste of the LookController however when using it on a player it causes the player to keep spinning and does not stop. The pitch is also incorrect causing it to look either at the sky or at the floor. Excuse me in advance for the extremely messy code, but I've been playing around with lots of numbers trying to get different results. My code is found here however the main code is these lines:

Posted

Howdy

 

When I've had similar trouble before, I've found it very useful to do a few different troubleshooting things

1) Kill off all entities except the one I'm testing and prevent any more from spawning, then using breakpoints (eg see this class https://github.com/TheGreyGhost/MinecraftByExample/blob/master/src/main/java/minecraftbyexample/usefultools/debugging/DebugSpawnInhibitor.java

2) Add code to the tick event which prints the relevant variables to the console, including whether the tick is on client or server thread

3) breaking the problem into small steps (i.e. just doing the yaw, just pointing the head in a desired direction, pointing the head at a particular point, etc)

 

Some problems I've had before

1) The units of rotation (degrees vs radians vs 1/256 of a circle)

2) mixing up the different head rotations - see here

http://greyminecraftcoder.blogspot.com/2015/07/entity-rotations-and-animation.html  (out of date but the concepts are still correct)

 

-TGG

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.