Advertisement
torako

Untitled

Feb 8th, 2025
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using Cysharp.Threading.Tasks.Triggers;
  4. using UnityEngine;
  5. using TMPro;
  6.  
  7. public class breakscript : MonoBehaviour
  8. {
  9.     public GameObject broken;
  10.     public TMP_Text magnitudeTextBox;
  11.     // Start is called before the first frame update
  12.     void Start()
  13.     {
  14.        
  15.     }
  16.     void OnCollisionEnter(Collision collision)
  17.     {
  18.         magnitudeTextBox.text = collision.relativeVelocity.sqrMagnitude.ToString();
  19.     }
  20.  
  21.     // Update is called once per frame
  22.     void Update()
  23.     {
  24.        
  25.     }
  26.     public void BreakThing()
  27.     {
  28.         Instantiate(broken, transform.position, transform.rotation);
  29.         Destroy(gameObject);
  30.     }
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement