dronkowitz

Speeder.cs (Sonic Heroes)

Feb 1st, 2021 (edited)
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Speeder : MonoBehaviour
  6. {
  7.  
  8.     private float force = 20000;
  9.     GameObject source;
  10.     public AudioClip clip;
  11.  
  12.  
  13.     public void OnTriggerEnter(Collider other)
  14.     {
  15.  
  16.  
  17.  
  18.         if (other.TryGetComponent(out Rigidbody body))
  19.         {
  20.             body.velocity = Vector3.zero;
  21.             body.AddForce(transform.forward * force);
  22.             body.transform.rotation = transform.rotation;
  23.  
  24.             GameObject ao = Instantiate(source, transform.position, Quaternion.identity);
  25.             ao.GetComponent<AudioObject>().Setup(clip, transform);
  26.  
  27.  
  28.             if (other.TryGetComponent(out UltimatePlayerMovement player))
  29.             {
  30.                 //player.SurrenderControl(0.3f);
  31.             }
  32.         }
  33.     }
  34.  
  35.  
  36.  
  37.     // Start is called before the first frame update
  38.     void Start()
  39.     {
  40.         source = Resources.Load<GameObject>("Audio Object");
  41.     }
  42.  
  43.     // Update is called once per frame
  44.     void Update()
  45.     {
  46.  
  47.     }
  48.  
  49.     public void OnTriggerExit(Collider other)
  50.     {
  51.  
  52.     }
  53. }
  54.  
Advertisement
Add Comment
Please, Sign In to add comment