Posted February 26, 20232 yr Hello. I was searching the signification of the method getInputVector(). I've found it in Entity.java private static Vec3 getInputVector(Vec3 pRelative, float pMotionScaler, float pFacing) { double d0 = pRelative.lengthSqr(); if (d0 < 1.0E-7D) { return Vec3.ZERO; } else { Vec3 vec3 = (d0 > 1.0D ? pRelative.normalize() : pRelative).scale((double)pMotionScaler); float f = Mth.sin(pFacing * ((float)Math.PI / 180F)); float f1 = Mth.cos(pFacing * ((float)Math.PI / 180F)); return new Vec3(vec3.x * (double)f1 - vec3.z * (double)f, vec3.y, vec3.z * (double)f1 + vec3.x * (double)f); } } Here is another function which uses the getInputVector : public void moveRelative(float pAmount, Vec3 pRelative) { Vec3 vec3 = getInputVector(pRelative, pAmount, this.getYRot()); this.setDeltaMovement(this.getDeltaMovement().add(vec3)); } Could someone explain me what is the goal of this method please ?
February 26, 20232 yr 12 hours ago, Vat1n said: Could someone explain me what is the goal of this method please ? To set the movement of the entity towards the direction of the passed in vector.
February 26, 20232 yr Author Thank you for your answer. I understand now : Imagine you want to move diagonally (in relation to the axes X and Z), you have to set X movement and Z movement. Then we'll have to deal with Pythagorean theorem or something like that in order to get the correct value for the diagonal movement 😄 Edited February 26, 20232 yr by Vat1n
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.