dronkowitz

TornadoJump.cs

Sep 29th, 2021 (edited)
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.46 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class TornadoJump : MonoBehaviour
  6. {
  7.     public GameObject pole;
  8.     public GameObject ExitPole;
  9.     public GameObject JumpDirection;
  10.     public bool tornadoJump;
  11.     public bool teamSwing;
  12.     public float startingSpeed = 5.0f;
  13.     public float maxStartingSpeed = 10.0f;
  14.     public float jumpForce;
  15.     // Start is called before the first frame update
  16.     void Start()
  17.     {
  18.        
  19.     }
  20.  
  21.     // Update is called once per frame
  22.     void Update()
  23.     {
  24.        
  25.     }
  26.     public void RotateToSwing(GameObject speedCharacter)
  27.     {
  28.  
  29.     }
  30.     public void OnTriggerStay(Collider other)
  31.     {
  32.         if (other.CompareTag("Player") && Input.GetKeyDown(KeyCode.B))
  33.         {
  34.             StartCoroutine(Swinging(other.gameObject));
  35.         }
  36.     }
  37.     public void Swing()
  38.     {
  39.  
  40.     }
  41.     public IEnumerator Swinging(GameObject speedCharacter)
  42.     {
  43.         NewPlayerMovement.controllable = false;
  44.         speedCharacter.GetComponent<Rigidbody>().useGravity = false;
  45.         speedCharacter.GetComponentInParent<NewPlayerMovement>().body.velocity = Vector3.zero;
  46.         speedCharacter.GetComponent<NewPlayerMovement>().LeftTeamMember.SetActive(false);
  47.         speedCharacter.GetComponent<NewPlayerMovement>().RightTeamMember.SetActive(false);
  48.  
  49.         speedCharacter.transform.position = transform.position;
  50.         //speedCharacter.GetComponentInChildren<Animator>().Play("Tornado Jump");
  51.        
  52.  
  53.         while (speedCharacter.transform.position.y < ExitPole.transform.position.y)
  54.         {
  55.             //speedCharacter.GetComponent<Rigidbody>().AddForce(new Vector3(0, startingSpeed, 0));
  56.             speedCharacter.transform.Translate(new Vector3(0, startingSpeed, 0));
  57.             if (speedCharacter.GetComponent<Rigidbody>().velocity.y > maxStartingSpeed)
  58.             {
  59.                 speedCharacter.GetComponent<Rigidbody>().velocity = new Vector3(0, maxStartingSpeed, 0);
  60.             }
  61.  
  62.             yield return new WaitForSeconds(Time.deltaTime);
  63.  
  64.  
  65.         }
  66.  
  67.         speedCharacter.transform.position = ExitPole.transform.position;
  68.  
  69.         Vector3 jumpDirection = ExitPole.transform.position + JumpDirection.transform.position;
  70.         jumpDirection = jumpDirection.normalized;
  71.         jumpDirection *= jumpForce;
  72.         speedCharacter.GetComponent<CharacterController>().Move(jumpDirection);
  73.  
  74.        
  75.         yield return null;
  76.     }
  77.  
  78.    
  79. }
  80.  
  81.  
Add Comment
Please, Sign In to add comment