c# - Rotate MainCamera by z-angle after using an item -


trying undertand unity4 , having troubles. idea of 3d game collect mushrooms , them. 1 of possible effects changing , down. positions of earth , sky exchange. i've tryed camera rotation. suppose doing wrong.

override public void use(){     this.activated = true; }  override public void update(){     base.update ();     if (this.activated) {                camera.main.transform.rotate(vector3.forward, 180);     } } 

after using mushroom main camera starts jumping , rotating crazy angles in short time. should stay stable , change self correct player inputs.

what mistakes , can differently? attention.

the answer of user1711383 helped not perfectly.

did'not explaiden whole situtation. works in inventory. after push 'i' inversion disappears. used

public bool visible=false; public guiskin skin; public mouselook player; public mouselook cam;  void update(){     if (input.getkeydown (keycode.i)) {         visible=!visible;         player.enabled = !visible;         cam.enabled = !visible;     }  }  void ongui(){     if (visible) {         gui.skin = skin;         gui.window(0,new rect((screen.width-1024)/2,0,1024,600),inventorybody,"inventory");     } } 

your call rotate continue happen unless set activated false again.

override public void update(){     base.update ();     if (this.activated) {                camera.main.transform.rotate(vector3.forward, 180);         this.activated = false;     } } 

consider using vector3.lerp() smooth movement between 2 states. there video tutorial includes it. https://unity3d.com/learn/tutorials/projects/stealth/camera-movement


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -