Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.28 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5.  
  6.  
  7. public class player : MonoBehaviour
  8. {
  9.     Animator anim;
  10.     Rigidbody2D rb;
  11.     public float speed;
  12.     float thisSpeed;
  13.     bool fright;
  14.  
  15.  
  16.     void Start ()
  17.     {
  18.         anim = GetComponent<Animator>();
  19.         rb = GetComponent<Rigidbody2D>();
  20.     }
  21.    
  22.     void Update ()
  23.     {
  24.        
  25.     }
  26.  
  27.     void FixedUpdate()
  28.     {
  29.         if (Input.GetKey(KeyCode.A))
  30.         {
  31.             thisSpeed = -speed;
  32.             anim.SetInteger("penis",2);
  33.         }
  34.         else if (Input.GetKey(KeyCode.D))
  35.         {
  36.             thisSpeed = +speed;
  37.             anim.SetInteger("penis", 2);
  38.         }
  39.         else
  40.         {
  41.             anim.SetInteger("penis", 4);
  42.         }
  43.  
  44.         if (Input.GetKey(KeyCode.R))
  45.         {
  46.            
  47.         }
  48.  
  49.         transform.Translate(thisSpeed, 0, 0);
  50.         thisSpeed = 0;
  51.  
  52.         if (thisSpeed < 0 && fright)
  53.         {
  54.             Flip();
  55.         }
  56.         if (thisSpeed > 0 && !fright)
  57.         {
  58.             Flip();
  59.         }
  60.     }
  61.  
  62.     void Flip()
  63.     {
  64.         fright = !fright;
  65.         transform.localScale = new Vector3(transform.localScale.x * -1, transform.localScale.y, transform.localScale.z);
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement