- Home /
Question by
felsefiyen · Dec 06, 2018 at 07:26 AM ·
c#objectobjectscount
counting of two different objects
Hello there. I created two separate objects. When I press the A button, I hit the basketball and when I press the K key, the capsule falls. I've set an area and I want to keep the number of basketball balls and capsules falling apart. When any object falls into the field, two numbers are increasing at the same time. The number of bounces after a fall, the second time falls to the number is increasing one more. How can I fix this?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class objegirdisi : MonoBehaviour {
public GUIStyle puanstil;
public GUIStyle kapsulstil;
private int topadet=0;
private int kapsuladet = 0;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnTriggerEnter(Collider go)
{
topadet++;
kapsuladet++;
Debug.Log("Kutu Icerisine Giren Nesne: "+go.name);
}
void OnGUI()
{
GUI.Label(new Rect(0,0,Screen.width,50),topadet+"",puanstil);
GUI.Label(new Rect(0, 30, Screen.width, 50), kapsuladet + "", kapsulstil);
}
}
Comment
Your answer
Follow this Question
Related Questions
Counting active objects in a list 3 Answers
Get the amout of objects in a given position 1 Answer
I need a grid of objects at runtime, but the gameObject is instantiated later 0 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers