unity3d - Unity -- Camera Child of Player Rotates Uncontrollably -


i have camera want stay @ times @ same position player. did making child of player, since when did through script player got ahead of camera. have camera rotating mouse. however, when made camera child of player, player , camera don't stop rotating, continue when mouse motionless. want camera rotate when mouse moving. code (js):

    #pragma strict var player : gameobject; function start () {     player = gameobject.find("player");     cursor.visible = false; }  function update () {     //transform.position = player.transform.position;     transform.rotate(input.getaxis("mouse y") * -2, input.getaxis("mouse x") * 5, 0);     transform.rotation.eulerangles = new vector3(transform.rotation.eulerangles.x, transform.rotation.eulerangles.y, 0);     //player.transform.rotation = transform.rotation; } 

first commented out line now-unnecessary code moves camera player, second line 1 causing problems. if remove it, camera rotates fine player can't turn (transform.forward-based controls). if uncomment it, player , camera turn no friction , can't controlled.

this isn't how make mouse controller. should take @ these controllers:

https://forum.unity.com/threads/a-free-simple-smooth-mouselook.73117/

http://wiki.unity3d.com/index.php/smoothmouselook

or js one: http://answers.unity3d.com/answers/367253/view.html


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -