# [1.7.10] RotationYaw drives me nut

## Recommended Posts

Hi guys,

I have a new water mob which is a fish. I have no issue moving it around in the water. BUT the rotation yaw gives me headaches.

It always seems that the mob moves sideways or backward before adjusting the yaw correctly.

It does work at some point, but the fish always travel some distance before having the correct yaw. I would like it to point in the correct direction BEFORE starting to move.

What am I doing wrong?

Is it because the client side get the yaw value too late, after the server start to send new positions?

This is how I calculate my yaw (look in bold) during the updateaitask while starting to move ... I took it from the ghast class in forge. I tested few methods, all with similar results.

public static void SwimTo(EntityFantasticFish aWaterMob, double xCoor, double yCoor, double zCoor, double speed)

{

if ((aWaterMob!=null) && (aWaterMob.isEntityAlive()))

{

if (!aWaterMob.worldObj.isRemote)

{

//Distance to target

double distX = Math.abs(xCoor - aWaterMob.posX);

double distY = Math.abs(yCoor - aWaterMob.posY);

double distZ = Math.abs(zCoor - aWaterMob.posZ);

if ((distX<=0.5) && (distY<=0.5) && (distZ<=0.5))

{

//Stay still

aWaterMob.setVelocity(0, 0, 0);

aWaterMob.SetCurrentSpeed(0F);

}

else

{

//Create vector

Vec3 vec3 = Vec3.createVectorHelper(xCoor - aWaterMob.posX, yCoor - aWaterMob.posY, zCoor - aWaterMob.posZ).normalize();

//Get approaching speed

//Set motion and angles

//Yaw from the ghast code

aWaterMob.renderYawOffset = aWaterMob.rotationYaw = -((float)Math.atan2(aWaterMob.motionX, aWaterMob.motionZ)) * 180.0F / (float)Math.PI;

}

}

}

}

And this is what I have in the model class:

public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity)

{

super.setRotationAngles(f, f1, f2, f3, f4, f5, entity);

EntityFantasticFish _fish = (EntityFantasticFish)entity;

this.mouth.rotateAngleX = 0.17F*(MathHelper.cos(f2 * 0.06662F) ) + 0.8726646F;

this.bodysection1.rotateAngleY = 0.2F *(MathHelper.cos(f2 * _fish.GetTailFlapSpeed() * 0.527F) );

this.bodysection2.rotateAngleY = 0.2F *(MathHelper.cos(f2 *_fish.GetTailFlapSpeed() * 0.527F - (float)(Math.PI/6)) );

this.bodysection3.rotateAngleY = 0.2F *(MathHelper.cos(f2 *  _fish.GetTailFlapSpeed() * 0.527F - (float)(Math.PI/3)) );

this.bodysection4.rotateAngleY = 0.2F *(MathHelper.cos(f2 * _fish.GetTailFlapSpeed() * 0.527F - (float)(Math.PI/2)) );

this.bodysection5.rotateAngleY = 0.2F *(MathHelper.cos(f2 *  _fish.GetTailFlapSpeed() * 0.527F - (float)(2*Math.PI/3)) );

this.bodysection6.rotateAngleY = 0.2F *(MathHelper.cos(f2 * _fish.GetTailFlapSpeed() * 0.527F - (float)(5*Math.PI/6)) );

}

##### Share on other sites

Try adjusting rotationYaw on both side, not only Server side.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

##### Share on other sites

Try adjusting rotationYaw on both side, not only Server side.

I was under the impression that the server and client where always in synch as far as the basic rendering parameters (pitch, yaw, position). Am I wrong?

Any of you guys are doing manual synching for those rendering parameters?

##### Share on other sites

And ...

does my rotationyaw formula make sense?

## 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.

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

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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

• ### Posts

• I figured out the problem eventually. My friend didn't know that entire new versions of the mod pack had come out and thus all I needed to do was try all the previous versions until one worked. There were a lot of mod updates despite the game only telling me that two mods were out of date.
• tôi muốn dùng mod để sinh tồn
• bro I already did that, that is not the problem

• ### Who's Online (See full list)

×

• #### Activity

×
• Create New...