Scrpts
Scrpts
GameManager.cs
using UnityEngine;
using UnityEngine.SceneManagement;
void Start()
{
blocksLeft= GameObject.FindGameObjectsWithTag("Block").Length;
Debug.Log(blocksLeft);
}
public void DecreaseBlocks()
{
blocksLeft--;
Debug.Log(blocksLeft);
if (blocksLeft == 0)
{
LoadNextScene();
}
}
}
BallCollision.cs
using UnityEngine;
using UnityEngine;
Rigidbody2D rb;
bool isBallLaunched;
void Start()
{
rb = GetComponent<Rigidbody2D>();
void Update()
{
if (Input.GetButtonDown("Launch") && !isBallLaunched)
{
Launch();
}
}
void Launch()
{
isBallLaunched = true;
rb.AddForce(launchForce);
transform.parent = null;
}
}
PlayerMovement.cs
using UnityEngine;
void Update()
{
Move();
}
void Move()
{
float xInput = Input.GetAxisRaw("Horizontal");
float newPositionX = transform.position.x + speed * xInput * Time.deltaTime;