Advertisement
gandalfbialy

Untitled

May 10th, 2025
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. using UnityEditor;
  2. using UnityEngine;
  3.  
  4. public class ArcanoidBall : MonoBehaviour
  5. {
  6.     public float speed = 5f;
  7.     Rigidbody rb;
  8.  
  9.     // Start is called once before the first execution of Update after the MonoBehaviour is created
  10.     void Start()
  11.     {
  12.         rb = GetComponent<Rigidbody>();
  13.         //RunBall();
  14.     }
  15.     // Update is called once per frame
  16.     void Update()
  17.     {
  18.        
  19.     }
  20.     public void RunBall()
  21.     {
  22.         float x = Random.Range(0, 2) == 0 ? -1 : 1;
  23.         rb.velocity = new Vector3(x * speed, speed, 0f);
  24.         //rb.linearVelocity = new Vector3(x * speed, speed, 0f);
  25.     }
  26.     public void StopBall()
  27.     {
  28.         rb.velocity = new Vector3(0, 0, 0);
  29.     }
  30.     private void OnCollisionEnter(Collision collision)
  31.     {
  32.         if (collision.gameObject.name == "LoseWall")
  33.         {
  34.             GameManager.instance.EndGame(false);
  35.             Debug.Log("Przegrana!");
  36.             this.gameObject.GetComponent<Renderer>().enabled = false;
  37.         }
  38.     }
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement