dronkowitz

LightSpeed.cs

Aug 30th, 2021 (edited)
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.85 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class LightSpeed : MonoBehaviour
  6. {
  7.     public bool lightspeedattack;
  8.     public bool ringtrail;
  9.     public List<GameObject> rings = new List<GameObject>();
  10.     // Start is called before the first frame update
  11.     void Start()
  12.     {
  13.  
  14.     }
  15.  
  16.     // Update is called once per frame
  17.     void Update()
  18.     {
  19.        
  20.     }
  21.     public void DashPrep(GameObject speedCharacter)
  22.     {
  23.         string charname = speedCharacter.gameObject.name;
  24.         if (charname != "Sonic The Hedgehog" || charname != "Shadow The Hedgehog" || charname != "Super Sonic")
  25.         {
  26.             return;
  27.         }
  28.         speedCharacter.GetComponent<Rigidbody>().useGravity = false;
  29.         speedCharacter.GetComponentInParent<NewPlayerMovement>().body.velocity = Vector3.zero;
  30.         speedCharacter.GetComponent<Animator>().Play("Light Speed Attack");
  31.         StartCoroutine(Dash(speedCharacter));
  32.     }
  33.  
  34.     public IEnumerator Dash(GameObject SpeedCharacter)
  35.     {
  36.         int counter = 0;
  37.         while (counter < rings.Count)
  38.         {
  39.             SpeedCharacter.transform.position = rings[counter].transform.position;
  40.  
  41.             yield return new WaitForSeconds(0.1f);
  42.             counter += 1;
  43.         }
  44.         DashExit(SpeedCharacter);
  45.     }
  46.     public void DashExit(GameObject SpeedCharacter)
  47.     {
  48.         SpeedCharacter.GetComponent<Rigidbody>().useGravity = true;
  49.         SpeedCharacter.GetComponentInParent<NewPlayerMovement>().body.velocity = Vector3.zero;
  50.         SpeedCharacter.GetComponent<Animator>().Play("Jump Down");
  51.  
  52.     }
  53.     public void OnTriggerStay(Collider other)
  54.     {
  55.        
  56.         if (other.GetComponent<NewPlayerMovement>() == true && Input.GetKeyDown(KeyCode.B))
  57.         {
  58.             DashPrep(other.gameObject);
  59.         }
  60.     }
  61. }
  62.  
  63.  
Add Comment
Please, Sign In to add comment