Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Mob animations issue


DoorCloser
 Share

Recommended Posts

Ok, so there is a strange thing in mob's animations. So, looks like i want my mob to perform walking animations, i do.

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);
    this.rightleg.rotateAngleX = MathHelper.cos(f * 0.5F) * -1.0F * f1;
this.leftleg.rotateAngleX = MathHelper.cos(f * 0.5F) * 1.0F * f1;

this.rightarm.rotateAngleX = MathHelper.cos(f * 0.5F) * -1.0F * f1;
this.leftarm.rotateAngleX = MathHelper.cos(f * 0.5F) * 1.0F * f1;
  }

}

 

And it works, but always when i set an animation on any limb, on X angle, the rotation of that limb on X angle is become 0. I know its hard to understand. So let me explain better

 

Here is the part of code of your ModelMob.class

leftarm = new ModelRenderer(this, 120, 29);
      leftarm.addBox(-8F, 5F, -1.8F, 2, 12, 2);
      leftarm.setRotationPoint(8.5F, 3F, 3F);
      leftarm.setTextureSize(128, 64);
      leftarm.mirror = true;
      setRotation(leftarm, -0.5420432F, 0F, 0F);

 

You see, that setRotation is going on -0.5, so basicly that arm is a littlebit turned in game. But when i use an animation...

this.leftarm.rotateAngleX = MathHelper.cos(f * 0.5F) * 1.0F * f1;

 

... in game, that arm perform animation while mob is walking, but when he is idle, that arm is no more turned. Its now straight down on X angle. So before i set animations it was (-0.5F) in game, after that its (0F). Any ideas on how to fix it?

Link to comment
Share on other sites

imo, pretty hard to understand.

 

pics pls for noobs like me.

 

Look. So, on the first pic you see, that i have this code in my ModelMob.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);
    this.rightupperleg.rotateAngleX = MathHelper.cos(f * 0.5F) * -1.0F * f1;
this.leftupperleg.rotateAngleX = MathHelper.cos(f * 0.5F) * 1.0F * f1;

this.rightupperarm.rotateAngleX = MathHelper.cos(f * 0.4F) * -1.2F * f1;
this.leftupperarm.rotateAngleX = MathHelper.cos(f * 0.4F) * 1.2F * f1;


  }

So, only rightarm is childed by rightupperarm, so its moving with it. But when i do so:

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);
this.rightupperleg.rotateAngleX = MathHelper.cos(f * 0.5F) * -1.0F * f1;
this.leftupperleg.rotateAngleX = MathHelper.cos(f * 0.5F) * 1.0F * f1; 



this.rightupperarm.rotateAngleX = MathHelper.cos(f * 0.4F) * -1.2F * f1;
this.leftupperarm.rotateAngleX = MathHelper.cos(f * 0.4F) * 1.2F * f1;
this.rightarm.rotateAngleX = MathHelper.cos(f * 0.5F) * -1.0F * f1; // i just added these
this.leftarm.rotateAngleX = MathHelper.cos(f * 0.5F) * 1.0F * f1; // i just added these


  }

...mob's arms are straight down.

So, basicly you see on the first picture, that the both lowerarms ( which is rightarm,leftarm in the code ) are rotated a littlebit( while mob is idle ), but when i set to them animations while walking (rightarm, leftarm), they made not rotated( while mob is idle ) by the X Angle (  because rotateAngleX ), thats on the second picture. I HOPE you understand.

width=640 height=359http://s17.postimg.org/a9cxmdtyn/2014_02_11_03_12_16.png[/img]

width=640 height=359http://s17.postimg.org/4ml62ngtr/2014_02_11_03_13_21.png[/img]

image share

Link to comment
Share on other sites

imo, pretty hard to understand.

 

pics pls for noobs like me.

 

So, did you understand? Before i add walking animations, while mob is idle he was having arm like this "/" but when i added walking animations, now while he  idle, his arms was looks like this "|". Any guesses on how to add walking animations on limb and make that limb rotated how i want

Link to comment
Share on other sites

Basic math.

From your code, when you have a rotation of 0° (which is idle), the code only multiplies values which means 0 * [a value] * [another value] = 0

And yes, Math.cos(0) is 1, but the second parameter (here f1) is also 0, so in all it's 0

 

When it moves, the values have a value != 0, so you'll have a difference between the rotation of the upper and lower part, since they multiply with different values.

 

 

Solution? Add a standard rotation to the calculated value, like rightarm.rotateAngleX = Math.cos(...) * ... + [rotation]

Play with the value of [rotation] until it's right. Or take the value from the model constructor, where you initialize the rightarm ModelRenderer.

 

Little note: I made the effort and tried to find out what those setRotationAngles (and some other methods) parameters mean (or what they should be called). You can see the result here:

https://github.com/SanAndreasP/EnderStuffPlus/blob/master/java/sanandreasp/mods/EnderStuffPlus/client/model/ModelEnderIgnis.java#L154

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

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

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.