# Best way to rotate a physics-object based on input

I am trying to rotate a certain object which has a rigidbody and some colliders. The rotation is based on user input and must be applied directly and always the same (i.e. it should not be influenced by other physics objects).

What I tried:

1. Make the object kinematic and change it's rotation every frame -> fail, because of tunneling
2. Make the object kinematic and change it's angular velocity every frame -> fail, kinematic objects cannot have velocity (that is weird, because this is the way I do it in other engines, like Box2D)
3. Keep the object dynamic (not kinematic) and change it's angular velocity every frame -> fail, because other objects have influence on the final rotation.
4. Attach a configurable joint to it and change it's target rotation every frame -> fail, because other objects have influence on the final rotation.
5. Attach a configurable joint to it and change it's angular limits every frame -> fail, because other objects have influence on the final rotation.
6. Make the object kinematic, attach a configurable joint to it and change it's target rotation every frame -> fail, because the joint drivers don't work on kinematic objects.

So, I'm kinda out of ideas here. I hope someone has a nice suggestion?

Here's a JavaScript I made that should work when attached to a kinematic rigidbody.

``````var speed=90;
//The above defines the speed at which this object will rotate when the
//x axis is not zero.

function Update(){
var x=Input.GetAxis("Horizontal")*Time.deltaTime*speed;
transform.Rotate(0,x,0);
}
//The above rotates this object at the speed of "speed" degrees per
//second in the direction pressed.

``````

You can place the object on a unique layer, this way no other physics objects will have influence over it if you choose to turn that off in that layer. Then do as you please with it.

If you need it to feed information about it's position to other objects for their physics, create a dummy object in the right layer for objects you want to influence, turn off the dummy object's rendering, but add joints or nest objects or whatever you need do, then get the transform information regularly from your player controlled object and pass it to the dummy object as regularly as needed.