Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var player : GameObject;
- function FixedUpdate () {
- transform.position = player.transform.position;
- // Debug.Log("player.rb.vel: " + player.rigidbody.velocity + "; transform.rotation: " + transform.rotation);
- // -x is left, +x is right
- // -z is down, +z is up
- // transform.rotation.y -- 90 is right, -90 is left, 0 is up, 180 is down
- /*
- 0
- +Z
- -90 -X +X 90
- -Z
- 180
- */
- if(player.rigidbody.velocity.z > 0) {
- yRotation = 0.0 + Input.GetAxis("Horizontal");
- transform.eulerAngles = Vector3(0, yRotation, 0);
- Debug.Log("UP!");
- }
- if(player.rigidbody.velocity.z < 0) {
- yRotation = 180.0 + Input.GetAxis("Horizontal");
- transform.eulerAngles = Vector3(0, yRotation, 0);
- Debug.Log("DOWN!");
- }
- if(player.rigidbody.velocity.x < 0) {
- yRotation = 270.0 + Input.GetAxis("Horizontal");
- transform.eulerAngles = Vector3(0, yRotation, 0);
- Debug.Log("LEFT!");
- }
- if(player.rigidbody.velocity.x > 0) {
- yRotation = 90.0 + Input.GetAxis("Horizontal");
- transform.eulerAngles = Vector3(0, yRotation, 0);
- Debug.Log("RIGHT!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment