Jump to content

Mob animations issue


DoorCloser

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • https://drive.google.com/file/d/1M0EG-c5yfRd08DSnE5HVQNCu2v0YtA7A/view?usp=sharing  
    • so im not sure if your still watching this TileEntity but once we loaded a FTB modpack we wanted to run on the server it no longer seems to run. The console opens like normal but we've been sitting here for like a little over an hour and the server screen has not yet opened. Should we just keep waiting at this point?
    • I have now easily fixed the duplication error present, I was just not looking.   I have been working for the past half hour to try and fix another error present, this time with the Creative Mode Tab.   I have changed some things around to get where I am currently. (ModFoods to ModDrinks*) and it cannot find the symbol ".get" at the end of the code. *The custom class you recommended pOutput.accept(ModDrinks.ORANGE_JUICE.get()); I think the point I am at currently is the closest I have to how it should be but because I am not as experienced with java I would not know.  I have also removed ORANGE_JUICE and LEMON_JUICE from the ModFoods class, to avoid confliction. I do hope all this can be fully resolved soon.  
    • [SOLVED]  public class RenderGUIHandler { @SubscribeEvent public void renderGUI(RenderGameOverlayEvent.Text event){ Client.hud.draw(); } } As I was playing around a little with the code, i found out about an option to change The RenderGameOverlayEvent.Post to RenderGameOverlayEvent.Text
    • public class HUD { public Minecraft mc = Minecraft.getMinecraft(); public static class ModuleComparator implements Comparator<Module>{ @Override public int compare(Module o1, Module o2) { if (Minecraft.getMinecraft().fontRendererObj.getStringWidth(o1.name) > Minecraft.getMinecraft().fontRendererObj.getStringWidth(o2.name)){ return -1; } if (Minecraft.getMinecraft().fontRendererObj.getStringWidth(o1.name) < Minecraft.getMinecraft().fontRendererObj.getStringWidth(o2.name)){ return 1; } return 0; } } public void draw(){ ScaledResolution sr = new ScaledResolution(mc); FontRenderer fr = mc.fontRendererObj; Collections.sort(Client.modules, new ModuleComparator()); GlStateManager.pushMatrix(); GlStateManager.translate(4,4,0); GlStateManager.scale(1.5,1.5,1); GlStateManager.translate(-4, -4, 0); fr.drawString("Skyline", 10, 10, -1); GlStateManager.popMatrix(); int count = 0; for (Module m : Client.modules){ if (!m.toggled || m.name.equals("TabGUI")) continue; int offset = count* (fr.FONT_HEIGHT + 6); GL11.glTranslated(0.0f, 0.0f, -1.0f); Gui.drawRect(sr.getScaledWidth() - fr.getStringWidth(m.name) - 10, offset, sr.getScaledWidth() - fr.getStringWidth(m.name) - 8, 6 + fr.FONT_HEIGHT + offset, -1); Gui.drawRect(sr.getScaledWidth() - fr.getStringWidth(m.name) - 8, offset, sr.getScaledWidth(), 6 + fr.FONT_HEIGHT + offset, 0x90000000); fr.drawString(m.name, sr.getScaledWidth() - fr.getStringWidth(m.name) - 4, offset + 4, -1); count++; } Client.onEvent(new EventRenderGUI()); } } I have just recently stumbled upon this Problem, where the HudRenderer renders the wrong section of the textures and therefore completely destroys the Minecraft Armour and Hunger Bar. I am currently thinking if it is an issue with the DrawRect changing something it shouldn't. But I couldn't find anything about it. (To keep things Clean, the function is Called from another file) public class RenderGUIHandler { @SubscribeEvent public void renderGUI(RenderGameOverlayEvent.Post event){ Client.hud.draw(); } } Any help would be greatly appreciated  
  • Topics

×
×
  • Create New...

Important Information

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