Posted April 11, 20205 yr 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: Set yaw and pitch Find yaw and pitch target Set player's yaw and pitch (This is just for demonstration of code. It is not broken)
April 13, 20205 yr 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.