Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *****************PARTIAL CODE START*****************
- void Update () {
- #region Player Body Rotation
- //Get our Mouse Position, convert to world space
- mousePos = Input.mousePosition;
- mousePos.z = 11.4f;
- mousePos = Camera.main.ScreenToWorldPoint(mousePos);
- //Is the mouse to the right of the player?
- if (mousePos.x > transform.position.x && facingDir == -1){
- //Change the way we are facing, start lerping
- facingDir = 1;
- myAnim.SetInteger("facingDir", facingDir);
- lerpStartTime = Time.time;
- lerpRot = true;
- lerpStartRot = playerBody.eulerAngles.y;
- lerpDestRot = 90;
- }
- else if (mousePos.x < transform.position.x && facingDir == 1) {
- //Change the way we are facing, start lerping
- facingDir = -1;
- myAnim.SetInteger("facingDir", facingDir);
- lerpStartTime = Time.time;
- lerpRot = true;
- lerpStartRot = playerBody.eulerAngles.y;
- lerpDestRot = 270;
- }
- #endregion
- //Get our movedirection
- moveDirection = new Vector2(Input.GetAxisRaw("Horizontal"), Input.GetAxisRaw("Vertical"));
- *****************PARTIAL CODE END*****************
- *****************PARTIAL CODE START*****************
- void FixedUpdate(){
- //Move our player left/right
- myRigid.velocity = new Vector3(moveDirection.x * moveSpeed * Time.deltaTime, myRigid.velocity.y, moveDirection.y * moveSpeed * Time.deltaTime);
- myAnim.SetFloat("playerXVelocity", myRigid.velocity.x);
- if(Mathf.Abs(myRigid.velocity.x) > 0){
- playerRunning = true;
- myAnim.SetBool("playerRunning", playerRunning);
- }
- else{
- playerRunning = false;
- myAnim.SetBool("playerRunning", playerRunning);
- }
- *****************PARTIAL CODE END*****************
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement