Shaking character - rigidbody plus transform.rotate

So. I’m using a rigidbody controller for my character. I need this to allow for walking on walls (or in this case trees). I also have my character jump off the tree (finally got that working! woot) and now I’m allowing him to glide.

I have a code that… “works” however, the character is very shaky. I wanted to make it so they still have gravity pulling them down (at a fraction of regular gravity) and a constant forward speed. Then they can use their up down left right arrow keys to change their forward. So… hitting up or down will change their rotation on the x-axis. (so pointing up or down) hitting left or right will change their rotation on the y and z axis… By that I mean… left will make the character turn left (positive direction on y axis) and negative rotation on z axis. (the z-axis turn is nessisary, as it doesn’t change the forward rotation of player, but it looks more … real to have a sort of… centripetal force appear to be at work.

if (flying){
  rigidbody.AddForce (-gravity/6 * rigidbody.mass * Vector3.up); // somewhat reduced gravity

myTransform.Translate (0,0,2*moveSpeed*Time.deltaTime); // constant speed in the forward direction

myTransform.Rotate (-Input.GetAxis("Forward")*turnSpeed*2*Time.deltaTime,Input.GetAxis("Turn")*turnSpeed*Time.deltaTime,-Input.GetAxis("Turn")*turnSpeed*3*Time.deltaTime);


I’ve narrowed it down to this area of the code. When I take out the z axis turning the shaking will stop… but the turn doesn’t look as nice :frowning: and the turning on the x axis using the forward button is also shaky. (vertical default… I renamed it) (turn is the horizontal default)
If you notice that I’ve also added an extra number in those two axis it is because without it, the turns are barely perceptible, and there is still shaking without adding those in there.

Is the shaking due to… using translate on rigid body while add force is working on that rigidbody? or… is it.

The only other thing I can think of is… while flying I have in another area of “Update” (btw that script above is in fixed update) while flying(and not trying to climb on a tree) make players normal = Vector3.up — shaking could be… the two lines trying to affect my normal… the only… axis that doesn’t shake me… is the axis that doesn’t change my normal (the turning when I’m not using the z-axis turn affect)

So… how do I make this… (code) only work when I’m not hitting the forward or turn buttons? (I’ve tried adding an additional if statement to test for buttons but it still shakes):

if (flying && !climbing){
    if(!Input.GetButton("Turn") || !Input.GetButton("Forward")){  

   surfaceNormal = Vector3.up; // surfaceNormal is a variable that the code uses to update players normal

the shaking was caused by two update functions fighting over control of myNormal.

– update trying to keep my Normal aligned to Vector3.up and
– my movement rotating my character so that myNormal was no longer Vector3.up

Not related to rigidbody in conjunction with transform movement after all.