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

    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
    • It is an issue with quark - update it to this build: https://www.curseforge.com/minecraft/mc-mods/quark/files/3642325
    • Remove Instant Massive Structures Mod from your server     Add new crash-reports with sites like https://paste.ee/  
    • Update your drivers: https://www.amd.com/en/support/graphics/amd-radeon-r9-series/amd-radeon-r9-200-series/amd-radeon-r9-280x
  • Topics

×
×
  • Create New...

Important Information

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