Advertisement
dronkowitz

Spring.cs - Script (Unity) From The Game - Sonic Heroes (Remake)

Jan 6th, 2021 (edited)
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.46 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Spring : MonoBehaviour
  6. {
  7.     GameObject source;
  8.     public AudioClip clip;
  9.     private int springForce = 8500;
  10.     private float surrenderTime = 0.8f;
  11.  
  12.     // Start is called before the first frame update
  13.     void Start()
  14.     {
  15.         source = Resources.Load<GameObject>("Audio Object");
  16.         //Using the Resources folder in the Assests folder you can load up any kind of object
  17.         //With this above line of code. It loads up a GameObject named "Audio Object" From the Resources folder
  18.         //And applies it to the source variable
  19.     }
  20.  
  21.     // Update is called once per frame
  22.     void Update()
  23.     {
  24.  
  25.     }
  26.  
  27.     void OnTriggerEnter(Collider other)
  28.     {
  29.        
  30.         if (other.CompareTag("Player"))
  31.        
  32.  
  33.        
  34.         {
  35.            
  36.             Rigidbody body = other.GetComponent<Rigidbody>();
  37.             body.velocity = Vector3.zero;
  38.             body.AddForce(transform.up * springForce);
  39.            
  40.             GameObject ao = Instantiate(source, transform.position, Quaternion.identity);
  41.             ao.GetComponent<AudioObject>().Setup(clip, transform);
  42.            
  43.             UltimatePlayerMovement player = other.GetComponent<UltimatePlayerMovement>();
  44.             //player.SurrenderControl(surrenderTime);
  45.         }
  46.  
  47.        
  48.  
  49.  
  50.        
  51.     }
  52.  
  53.     private void OnTriggerExit(Collider other)
  54.     {
  55.  
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement