Posted October 29, 201410 yr So I have a mob, and when its head turns the ears don't go with it and instead kind of stay in place. The nose follows the head so I don't get why the ears don't. Here is the code for the rotation: public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { this.head.rotateAngleX = f4 / (180F / (float)Math.PI); this.head.rotateAngleY = f3 / (180F / (float)Math.PI); this.nose.rotateAngleX = this.head.rotateAngleX; this.nose.rotateAngleY = this.head.rotateAngleY; this.ear.rotateAngleX = this.head.rotateAngleX; this.ear.rotateAngleY = this.head.rotateAngleY; this.ear2.rotateAngleX = this.head.rotateAngleX; this.ear2.rotateAngleY = this.head.rotateAngleY; I also all have my model pieces in the same positions just with different offsets. Here's a normal picture when it's facing me: Here's a picture when it turns its head: Don't mind the hat I haven't tried fixing that yet.
October 30, 201410 yr If you want them to move together they need to have the same rotation point. You didn't post the code where you set the rotation points, but I suspect you don't have them the same. Alternatively you can make the parts "child" parts to the head and then you only have to turn the head, using the addChild() method for the renderer parts. However, in that case the rotation points will be relative and probably have to be adjusted depending on how you set up your model pieces. Check out my tutorials here: http://jabelarminecraft.blogspot.com/
October 30, 201410 yr Author I do have the rotations points all the same. Here is the whole model class for any more reference: package wintercraft.render.models; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; import net.minecraft.util.MathHelper; public class ModelElf extends ModelBase { //fields ModelRenderer head; ModelRenderer nose; ModelRenderer ear; ModelRenderer ear2; ModelRenderer chest; ModelRenderer pants; ModelRenderer rightarm; ModelRenderer leftarm; ModelRenderer rightleg; ModelRenderer rightshoe; ModelRenderer leftleg; ModelRenderer leftshoe; ModelRenderer hatbrim; ModelRenderer hat1; ModelRenderer hat2; ModelRenderer hat3; ModelRenderer hat4; ModelRenderer hat5; ModelRenderer hat6; ModelRenderer hatpoof; public ModelElf() { textureWidth = 64; textureHeight = 128; head = new ModelRenderer(this, 0, 53); head.addBox(-4F, -8F, -4F, 6, 6, 6); head.setRotationPoint(1F, 6F, 0F); head.setTextureSize(64, 128); head.mirror = true; setRotation(head, 0F, 0F, 0F); nose = new ModelRenderer(this, 50, 29); nose.addBox(-1.5F, -5F, -6F, 1, 1, 3); nose.setRotationPoint(1F, 6F, 0F); nose.setTextureSize(64, 128); nose.mirror = true; setRotation(nose, 0F, 0F, 0F); ear2 = new ModelRenderer(this, 56, 0); ear2.addBox(-0.4F, -9F, -2.8F, 1, 4, 1); ear2.setRotationPoint(1F, 6F, 0F); ear2.setTextureSize(64, 128); ear2.mirror = true; setRotation(ear2, -0.3141593F, 0F, 0.2617994F); ear = new ModelRenderer(this, 56, 0); ear.addBox(-2.6F, -9.5F, -2.8F, 1, 4, 1); ear.setRotationPoint(1F, 6F, 0F); ear.setTextureSize(64, 128); ear.mirror = true; setRotation(ear, -0.3141593F, 0F, -0.2617994F); chest = new ModelRenderer(this, 19, 41); chest.addBox(0F, 0F, 0F, 7, 7, 4); chest.setRotationPoint(-3.5F, 4F, -2.5F); chest.setTextureSize(64, 128); chest.mirror = true; setRotation(chest, 0F, 0F, 0F); pants = new ModelRenderer(this, 15, 16); pants.addBox(-4F, 0F, -2F, 8, 5, 4); pants.setRotationPoint(0F, 11F, -0.5F); pants.setTextureSize(64, 128); pants.mirror = true; setRotation(pants, 0F, 0F, 0F); rightarm = new ModelRenderer(this, 40, 16); rightarm.addBox(-3F, -2F, -2F, 3, 9, 3); rightarm.setRotationPoint(-3.5F, 6F, 0F); rightarm.setTextureSize(64, 128); rightarm.mirror = true; setRotation(rightarm, 0F, 0F, 0.1396263F); leftarm = new ModelRenderer(this, 40, 16); leftarm.addBox(-1F, -2F, -2F, 3, 9, 3); leftarm.setRotationPoint(4.5F, 6F, 0F); leftarm.setTextureSize(64, 128); leftarm.mirror = true; setRotation(leftarm, 0F, 0F, -0.1396263F); rightleg = new ModelRenderer(this, 0, 16); rightleg.addBox(-2F, 0F, -2F, 3, 9, 3); rightleg.setRotationPoint(-1.7F, 15F, 0F); rightleg.setTextureSize(64, 128); rightleg.mirror = true; setRotation(rightleg, 0F, 0F, 0F); rightshoe = new ModelRenderer(this, 0, 29); rightshoe.addBox(-2.466667F, 6F, -4.4F, 4, 3, 6); rightshoe.setRotationPoint(2.7F, 15F, 0F); rightshoe.setTextureSize(64, 128); rightshoe.mirror = true; setRotation(rightshoe, 0F, 0F, 0F); leftleg = new ModelRenderer(this, 0, 16); leftleg.addBox(-2F, 0F, -2F, 3, 9, 3); leftleg.setRotationPoint(2.7F, 15F, 0F); leftleg.setTextureSize(64, 128); leftleg.mirror = true; setRotation(leftleg, 0F, 0F, 0F); leftshoe = new ModelRenderer(this, 0, 29); leftshoe.addBox(-7F, 6F, -4.4F, 4, 3, 6); leftshoe.setRotationPoint(2.7F, 15F, 0F); leftshoe.setTextureSize(64, 128); leftshoe.mirror = true; setRotation(leftshoe, 0F, 0F, 0F); hatbrim = new ModelRenderer(this, 25, 2); hatbrim.addBox(0F, 0F, 0F, 7, 1, ; hatbrim.setRotationPoint(-3.5F, -2.8F, -5F); hatbrim.setTextureSize(64, 128); hatbrim.mirror = true; setRotation(hatbrim, -0.122173F, 0F, 0F); hat1 = new ModelRenderer(this, 0, 0); hat1.addBox(0F, 0F, 0F, 6, 3, 6); hat1.setRotationPoint(-3F, -5F, -3.5F); hat1.setTextureSize(64, 128); hat1.mirror = true; setRotation(hat1, -0.1745329F, 0F, 0F); hat2 = new ModelRenderer(this, 0, 0); hat2.addBox(0F, 0F, 0F, 5, 3, 5); hat2.setRotationPoint(-2.5F, -6.8F, -2.1F); hat2.setTextureSize(64, 128); hat2.mirror = true; setRotation(hat2, -0.5410521F, 0F, 0F); hat3 = new ModelRenderer(this, 0, 0); hat3.addBox(0F, 0F, 0F, 4, 3, 4); hat3.setRotationPoint(-2F, -7.666667F, -0.5F); hat3.setTextureSize(64, 128); hat3.mirror = true; setRotation(hat3, -0.6981317F, 0F, 0F); hat4 = new ModelRenderer(this, 0, 0); hat4.addBox(0F, 0F, 0F, 3, 2, 3); hat4.setRotationPoint(-1.5F, -8.5F, 1.5F); hat4.setTextureSize(64, 128); hat4.mirror = true; setRotation(hat4, -0.9948377F, 0F, 0F); hat5 = new ModelRenderer(this, 0, 0); hat5.addBox(0F, 0F, 0F, 2, 3, 2); hat5.setRotationPoint(-1F, -9F, 3.4F); hat5.setTextureSize(64, 128); hat5.mirror = true; setRotation(hat5, -1.012291F, 0F, 0F); hat6 = new ModelRenderer(this, 0, 0); hat6.addBox(0F, 0F, 0F, 1, 2, 1); hat6.setRotationPoint(-0.5F, -9F, 5F); hat6.setTextureSize(64, 128); hat6.mirror = true; setRotation(hat6, -1.27409F, 0F, 0F); hatpoof = new ModelRenderer(this, 0, 39); hatpoof.addBox(0F, 0F, 0F, 2, 2, 2); hatpoof.setRotationPoint(-1F, -9.5F, 4.6F); hatpoof.setTextureSize(64, 128); hatpoof.mirror = true; setRotation(hatpoof, 0F, 0F, 0F); } public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5,entity); head.render(f5); nose.render(f5); ear.render(f5); ear2.render(f5); chest.render(f5); pants.render(f5); rightarm.render(f5); leftarm.render(f5); rightleg.render(f5); rightshoe.render(f5); leftleg.render(f5); leftshoe.render(f5); hatbrim.render(f5); hat1.render(f5); hat2.render(f5); hat3.render(f5); hat4.render(f5); hat5.render(f5); hat6.render(f5); hatpoof.render(f5); } private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5, Entity entity) { this.head.rotateAngleX = f4 / (180F / (float)Math.PI); this.head.rotateAngleY = f3 / (180F / (float)Math.PI); this.nose.rotateAngleX = this.head.rotateAngleX; this.nose.rotateAngleY = this.head.rotateAngleY; this.ear.rotateAngleX = this.head.rotateAngleX; this.ear.rotateAngleY = this.head.rotateAngleY; this.ear2.rotateAngleX = this.head.rotateAngleX; this.ear2.rotateAngleY = this.head.rotateAngleY; this.leftleg.rotateAngleX = MathHelper.cos(f * 0.6662F) * 2.0F * f1 * 0.5f; this.leftleg.rotateAngleY = 0.0f; this.rightleg.rotateAngleX = MathHelper.cos(f * 0.6662F + (float)Math.PI) * 1.4f * f1; this.rightleg.rotateAngleY = 0.0f; this.leftshoe.rotateAngleX = this.leftleg.rotateAngleX; this.leftshoe.rotateAngleY = this.leftleg.rotateAngleY; this.rightshoe.rotateAngleX = this.rightleg.rotateAngleX; this.rightshoe.rotateAngleY = this.rightleg.rotateAngleY; this.leftarm.rotateAngleX = MathHelper.cos(f * 0.6662F) * 2.0F * f1 * 0.5f; this.leftarm.rotateAngleZ = 0.0f; this.rightarm.rotateAngleX = MathHelper.cos(f * 0.6663F + (float)Math.PI) * 1.4f * f1; this.rightarm.rotateAngleZ = 0.0f; } }
October 31, 201410 yr That is weird because it looks pretty straight-forward and I can't see any obvious problem. The one thing I'm slightly suspicious about though is that you didn't center the rotation point in the head. Your head box is 6 x 6 x 6 and so the offset should probably be -3 in the X and Z dimensions not -4. The problem a lot of people encounter with models is that they use offsets to erroneously compensate for bad rotation point alignment. Basically you can make a model look like all the pieces are connected with the offsets but that can break down when rotating if the rotation points weren't set up properly first. Anyway, what happens if you add 1 to the X and Z offsets (the first and third parameter of the addBox() methods for the head and everything attached to it (ears, nose, hat)? Check out my tutorials here: http://jabelarminecraft.blogspot.com/
November 4, 201410 yr Author Sorry for such a long wait but I tried that and still have the same problem where the nose works fine but the ears still don't act correctly. Here is the changed code if needed: head = new ModelRenderer(this, 0, 53); head.addBox(-3F, -8F, -3F, 6, 6, 6); head.setRotationPoint(0F, 6F, 0F); head.setTextureSize(64, 128); head.mirror = true; setRotation(head, 0F, 0F, 0F); nose = new ModelRenderer(this, 50, 29); nose.addBox(-0.5F, -5F, -5F, 1, 1, 3); nose.setRotationPoint(0F, 6F, 0F); nose.setTextureSize(64, 128); nose.mirror = true; setRotation(nose, 0F, 0F, 0F); ear2 = new ModelRenderer(this, 56, 0); ear2.addBox(0.4F, -9F, -1.8F, 1, 4, 1); ear2.setRotationPoint(0F, 6F, 0F); ear2.setTextureSize(64, 128); ear2.mirror = true; setRotation(ear2, -0.3141593F, 0F, 0.2617994F); ear = new ModelRenderer(this, 56, 0); ear.addBox(-1.6F, -9.5F, -1.8F, 1, 4, 1); ear.setRotationPoint(0F, 6F, 0F); ear.setTextureSize(64, 128); ear.mirror = true; setRotation(ear, -0.3141593F, 0F, -0.2617994F);
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.