Posted February 20, 20187 yr I'm trying to animate an TESR. Well I already did it but I did it wrong (by increasing the counter in the rendering itself instead of update() in the tile class), I'm trying to move it to update() but the problem starts here... the rendering isn't smooth. I read to I need to use partialTicks for this kind of stuff but I don't understand how? I'm translating, scaling and rotating in my TESR. Any help would be greatly appreciated. Edited February 20, 20187 yr by Terrails
February 20, 20187 yr partialTicks is used to smooth animation by interpolating between ticks. For example (code from PneumaticCraft: Repressurized to smoothly animate rotations of the Assembly Drill - see https://github.com/TeamPneumatic/pnc-repressurized/blob/master/src/main/java/me/desht/pneumaticcraft/client/render/tileentity/RenderAssemblyDrill.java): void renderModel(TileEntityAssemblyDrill te, float partialTicks) { if (te != null) { float[] renderAngles = new float[5]; for (int i = 0; i < 4; i++) { renderAngles[i] = te.oldAngles[i] + (te.angles[i] - te.oldAngles[i]) * partialTicks; } renderAngles[4] = te.oldDrillRotation + (te.drillRotation - te.oldDrillRotation) * partialTicks; model.renderModel(0.0625f, renderAngles); } else { model.renderModel(0.0625f, new float[]{0, 0, 35, 55, 0}); } } The rotation angles and previous rotation angles are stored in the TE - every tick, the angles are updated as appropriate and the previous angles are copied into te.oldAngles[] (multiple angles in this case, since it's a robot arm which has several points of rotation). The actual render angles are calculated as an interpolation of the current and previous angles, based on partialTicks: renderAngle = oldAngle + (newAngle - oldAngle) * partialTicks. Of course, this can also apply to any other rendering: translations, scaling etc. But that's the principle.
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.