Guest User

Untitled

a guest
Aug 30th, 2012
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. var player : GameObject;
  2.  
  3. function FixedUpdate () {
  4. transform.position = player.transform.position;
  5. // Debug.Log("player.rb.vel: " + player.rigidbody.velocity + "; transform.rotation: " + transform.rotation);
  6. // -x is left, +x is right
  7. // -z is down, +z is up
  8. // transform.rotation.y -- 90 is right, -90 is left, 0 is up, 180 is down
  9. /*
  10. 0
  11. +Z
  12. -90 -X +X 90
  13. -Z
  14. 180
  15. */
  16. if(player.rigidbody.velocity.z > 0) {
  17. yRotation = 0.0 + Input.GetAxis("Horizontal");
  18. transform.eulerAngles = Vector3(0, yRotation, 0);
  19. Debug.Log("UP!");
  20. }
  21. if(player.rigidbody.velocity.z < 0) {
  22. yRotation = 180.0 + Input.GetAxis("Horizontal");
  23. transform.eulerAngles = Vector3(0, yRotation, 0);
  24. Debug.Log("DOWN!");
  25. }
  26. if(player.rigidbody.velocity.x < 0) {
  27. yRotation = 270.0 + Input.GetAxis("Horizontal");
  28. transform.eulerAngles = Vector3(0, yRotation, 0);
  29. Debug.Log("LEFT!");
  30. }
  31. if(player.rigidbody.velocity.x > 0) {
  32. yRotation = 90.0 + Input.GetAxis("Horizontal");
  33. transform.eulerAngles = Vector3(0, yRotation, 0);
  34. Debug.Log("RIGHT!");
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment