cuhpl
cuhpl
CC#
Created by cuhpl on 2/11/2023 in #help
❔ Hi,my flappy bird game script isnt working
The script in making is to show that the score counter incrreases when the gamobject(bird) collides with the trigger inbetween the pipes but it isnt working can someone check if its my script that is wrong or idk using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class logic : MonoBehaviour { public int playerscore; public Text score; [ContextMenu("IncreaseScore")] public void addScore() { playerscore = playerscore + 1; score.text = playerscore.ToString(); } } this script is to increase the score using System.Collections; using System.Collections.Generic; using UnityEngine; public class middlescript : MonoBehaviour { public logic logic; // Start is called before the first frame update void Start() { logic = GameObject.FindGameObjectWithTag("logic").GetComponent<logic>(); } // Update is called once per frame void Update() { } private void OnTriggerEnter2D(Collider2D collision) { logic.addScore(); } } this script is to communitcate to the script above and to add score whenever the gameobject collides with the trigger
10 replies