# [SOLVED] Axis of rotation in Physics

Hi all,

I am trying to create an axis and an element to rotate when a dynamic physics element collides with it. It works, but the axis doesn’t rotate in the axis I defined in Angular Factor of the RigidBody. I tried to set the Entity.Forward value in a adjustForward.js script without success too. Someone could help?

The link of the test is
Collision Test | Editor (playcanvas.com)

Firstly, the angular/linear factors are in world space. It means Y is always pointing up, no matter how the object is rotated.

Secondly, the way linear/angular factors work is they just damping the motion on those axis. Say, you set 0 for Y, it means the object will not move up/down (again, regardless how it is rotated).

If you want to lock rotation like in your example, where the box is locked in place and rotated to some angle, you want to use linear factor with zero for all axis preventing it from moving in world space (like you have now) and a six degree of freedom or a hinge constraint that locks its rotation to local Y. Using a constraint might be a bit advanced, but here is a project that demonstrates it:

https://playcanvas.com/project/618829/overview/physics-constraints

Edit:
Another trick you could do is change the orientation of that scene, so the box is always horizontal, no rotations. Then its local Y will match with world Y and you could use angular factor. Then you just change the gravity to point to the side, so it would still look like they are falling down.

2 Likes

Hey @LeXXik
Thanks a lot for pointing out the sample and for the great trick too!

1 Like