Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted
comment_145591

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);

double speedAdjustment;

 

 

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

speedAdjustment = ProvideApproachingSpeed(distX, distY, distZ);

 

//Set motion and angles

aWaterMob.motionX = (vec3.xCoord * speed)*speedAdjustment;

aWaterMob.motionY = (vec3.yCoord * speed)*speedAdjustment;

aWaterMob.motionZ = (vec3.zCoord * speed)*speedAdjustment;

 

//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)) );

  }

 

 

 

 

  • Author
comment_145616

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?

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.