Help me please, i found some threads with pretty similar problem, but i still dont get how to solve it.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HitWall : MonoBehaviour
{
// Start is called before the first frame update
GameObject LeftScore;
GameObject RightScore;
void Start()
{
LeftScore = GameObject.Find("LeftScore");
RightScore = GameObject.Find("RightScore");
}
// Update is called once per frame
void Update()
{
}
void OnCollisionEnter2D(Collision2D col) {
if ((col.gameObject.name == "Ball") || (GameObject.name == "WallLeft")){
RightScore.score = RightScore.score + 1;
}
else if ((col.gameObject.name == "Ball") || (GameObject.name == "WallRight")){
LeftScore.score = LeftScore.score + 1;
}
}
}