Quantcast
Channel: Questions in topic: "javascipt"
Viewing all articles
Browse latest Browse all 1875

My character's Y Rotation is not equal to camera's Y rotation.

$
0
0
https://www.youtube.com/watch?v=Mj5p-BOWvqs Apparently instead of the rotation being from 0-360, it's 0-1 with 1 being 180. public var gsp : float; public var maxGsp : float; public var acc : float; public var frc : float; public var cam : GameObject; public var camRot : float; function FixedUpdate () { if(Input.GetAxis ("Vertical")>0 || Input.GetAxis ("Horizontal")>0 ) { gsp += acc; } else if(Input.GetAxis ("Vertical")<0 || Input.GetAxis ("Horizontal")<0 ) { gsp += acc; } else { gsp -= frc; } if(gsp >= maxGsp) { gsp = maxGsp; } else if(gsp <= 0) { gsp = 0; } moveSp.z = (Input.GetAxis ("Vertical") * gsp / 12); moveSp.x = (Input.GetAxis ("Horizontal") * gsp / 12); //transform.localPosition.z += moveSp.z; //transform.localPosition.x += moveSp.x; transform.Translate(moveSp.x * Mathf.Cos(camRot) , 0 , moveSp.z * Mathf.Cos(camRot)); } //Movement Rules } function LateUpdate () { if(gsp != 0) { transform.rotation.y = cam.transform.rotation.y; } }

Viewing all articles
Browse latest Browse all 1875

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>