Advertisement
Guest User

Untitled

a guest
Sep 3rd, 2015
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. *****************PARTIAL CODE START*****************
  2. void Update () {
  3.  
  4. #region Player Body Rotation
  5. //Get our Mouse Position, convert to world space
  6. mousePos = Input.mousePosition;
  7. mousePos.z = 11.4f;
  8. mousePos = Camera.main.ScreenToWorldPoint(mousePos);
  9.  
  10. //Is the mouse to the right of the player?
  11. if (mousePos.x > transform.position.x && facingDir == -1){
  12.  
  13. //Change the way we are facing, start lerping
  14. facingDir = 1;
  15. myAnim.SetInteger("facingDir", facingDir);
  16. lerpStartTime = Time.time;
  17. lerpRot = true;
  18. lerpStartRot = playerBody.eulerAngles.y;
  19. lerpDestRot = 90;
  20. }
  21. else if (mousePos.x < transform.position.x && facingDir == 1) {
  22.  
  23. //Change the way we are facing, start lerping
  24. facingDir = -1;
  25. myAnim.SetInteger("facingDir", facingDir);
  26. lerpStartTime = Time.time;
  27. lerpRot = true;
  28. lerpStartRot = playerBody.eulerAngles.y;
  29. lerpDestRot = 270;
  30. }
  31. #endregion
  32.  
  33. //Get our movedirection
  34. moveDirection = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
  35.  
  36. *****************PARTIAL CODE END*****************
  37.  
  38. *****************PARTIAL CODE START*****************
  39. void FixedUpdate(){
  40.  
  41. //Move our player left/right
  42. myRigid.velocity = new Vector3(moveDirection.x * moveSpeed * Time.deltaTime, myRigid.velocity.y, moveDirection.y * moveSpeed * Time.deltaTime);
  43.  
  44. myAnim.SetFloat("playerXVelocity", myRigid.velocity.x);
  45.  
  46. if(Mathf.Abs(myRigid.velocity.x) > 0){
  47. playerRunning = true;
  48. myAnim.SetBool("playerRunning", playerRunning);
  49. }
  50. else{
  51. playerRunning = false;
  52. myAnim.SetBool("playerRunning", playerRunning);
  53. }
  54.  
  55. *****************PARTIAL CODE END*****************
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement