# Calculate the rotational force and its direction

Hello, how should I calculate the rotational force and its direction in terms of the player? Objects are tweened

What am I trying to do? To give the player “force” in the form of an impulse, which aims to enliven the game so much that when passing through these obstacles, it does not go straight like a string, but is slightly pushed to the side of rotation

Thanks for the ideas

I achieved a result with a very dirty solution

``````    //Calculating rotation velocity
this.rotation = this.entity.getRotation();
this.velocity.copy(this.rotation).sub(this.previousRotation).scale(1/dt);
this.previousRotation.copy(this.rotation);
//isNumeric checks if result is not Nan or is Finite
if (isNumeric(Math.sign(this.velocity.x)) && isNumeric(Math.sign(this.velocity.z))) {
//Using Math.sign to understand in which direction/axis object is rotating and apllying force
this.player.rigidbody.applyImpulse(Math.sign(this.velocity.x) * this.force, -20, Math.sign(this.velocity.z) * this.force);
}

``````

We calculate the rotation “velocity” and then use Math.sign to understand whether the number is positive or negative according to the axis, thus we get the “direction”. Velocity data is very different between platforms, for example one platform may show -0.65 on x and another 1.298229876982187-17 so I use the already set force.

Yes, the location of the player is not taken into account, but it is unlikely that anyone will try to pass the obstacle in a way that it “should not” be passed

getRotation returns a quaternion (4 dimensional vector), is that what you want?

Yeah seems like that wont cover all cases, I wonder what is the proper way to calculate angular velocity
I am facing an unclear problem, even though the entity is rotating to one side, sometimes the readings flip over for a short period of time, probably it is related to eulers