Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public bool upKeyReleased = false;
- public bool downKeyReleased = false;
- public bool leftKeyReleased = false; // not currently used
- public bool rightKeyReleased = false; // not currently used
- public bool upKeyPressed = false;
- public bool downKeyPressed = false;
- public bool leftKeyPressed = false; // not currently used
- public bool rightKeyPressed = false; // not currently used
- public bool jumpKeyPressed = false;
- public float speedF = 5;
- public float speedFF = 1.8F;
- public float speedB = 1.8F;
- public float TurnSpeed = 200;
- public float JumpSpeed = 10;
- public float i;
- public bool runF;
- public bool runB;
- public bool fall;
- public bool MayJump;
- public bool startedCounting;
- public bool teleported;
- public bool Jump;
- public bool death;
- public bool first;
- public Transform Player;
- public Rigidbody PlayerRagdoll;
- public Animator anim;
- public int CollisionCount = 0;
- public Slider slider;
- public AudioSource walksound;
- private Rigidbody rb;
- // Use this for initialization
- void Start()
- {
- rb = GetComponent<Rigidbody>();
- startedCounting = false;
- death = false;
- slider = Slider.FindObjectOfType<Slider>();
- AudioSource walksound = GetComponent<AudioSource>();
- }
- void Update()
- {
- if (Input.GetKeyUp(KeyCode.W) || Input.GetKeyUp(KeyCode.UpArrow))
- {
- upKeyReleased = true;
- upKeyPressed = false;
- }
- else if (Input.GetKeyUp(KeyCode.S) || Input.GetKeyUp(KeyCode.DownArrow))
- {
- downKeyReleased = true;
- downKeyPressed = false;
- }
- else if (Input.GetKeyUp(KeyCode.A) || Input.GetKeyUp(KeyCode.LeftArrow))
- {
- leftKeyReleased = true;
- leftKeyPressed = false;
- }
- else if (Input.GetKeyUp(KeyCode.D) || Input.GetKeyUp(KeyCode.RightArrow))
- {
- rightKeyReleased = true;
- rightKeyPressed = false;
- }
- else if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.UpArrow))
- {
- upKeyPressed = true;
- upKeyReleased = false;
- }
- else if (Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.DownArrow))
- {
- downKeyPressed = true;
- downKeyReleased = false;
- }
- else if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow))
- {
- leftKeyPressed = true;
- leftKeyReleased = false;
- }
- else if (Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.RightArrow))
- {
- rightKeyPressed = true;
- rightKeyReleased = false;
- }
- if (upKeyReleased || fall)
- {
- walksound.Stop();
- }
- else if (upKeyPressed && (!walksound.isPlaying))
- {
- walksound.Play();
- walksound.loop = true;
- }
- //if moving set run true
- if (upKeyPressed && !runB)
- {
- runF = true;
- }
- else
- {
- runF = false;
- }
- if (downKeyPressed && !runF)
- {
- runB = true;
- }
- else
- {
- runB = false;
- }
- // if not running running foreward animation and not falling
- if (runF && !runB && !fall && !this.anim.GetCurrentAnimatorStateInfo(0).IsName("run") && !this.anim.GetCurrentAnimatorStateInfo(0).IsName("fall"))
- {
- anim.Play("run", 0, 0f);
- print("running");
- }
- if (runB && !runF && !fall && !this.anim.GetCurrentAnimatorStateInfo(0).IsName("back") && !this.anim.GetCurrentAnimatorStateInfo(0).IsName("fall"))
- {
- anim.Play("back", 0, 0f);
- }
- if (Input.GetKey(KeyCode.Space) && MayJump == true)
- {
- Jump = true;
- }
- else
- {
- if (CollisionCount != 0)
- {
- Jump = false;
- }
- }
- slider.value -= Time.deltaTime;
- // if not running play idle animation
- if (!fall && !runB && !runF && !this.anim.GetCurrentAnimatorStateInfo(0).IsName("idle"))
- {
- anim.Play("idle", 0, 0f);
- }
- if (this.anim.GetCurrentAnimatorStateInfo(0).IsName("idle"))
- {
- fall = false;
- }
- if(CollisionCount == 0)
- {
- StartCoroutine("WaitSeconds");
- if (startedCounting && !this.anim.GetCurrentAnimatorStateInfo(0).IsName("fall") && fall)
- {
- anim.Play("fall", 0, 0f);
- }
- }
- else
- {
- startedCounting = false;
- }
- //if no collsion play falling animation
- if (CollisionCount > 0)
- {
- if (this.anim.GetCurrentAnimatorStateInfo(0).IsName("fall"))
- {
- fall = false;
- anim.Play("idle", 0, 0f);
- }
- }
- if (GameObject.Find("Stick_Figure_T-pose ragdoll(Clone)"))
- {
- Destroy(gameObject);
- }
- if (slider.value == 0)
- {
- MayJump = false;
- }
- else
- {
- MayJump = true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement