Hello,
I have a scene with 36 spheres. All with a collider. And a wall “mainwand”, that’s a plane-Object. This contains the game’s “control script”. Each sphere has its own script "kugel1skript … kugel36skript. The whole thing is an Android app. When I touch a sphere, the number should be reported to the control script via a function call. Unfortunately, this also works when I touch another place.
here is the kugel1skript
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Kugel1skript : MonoBehaviour
{
// Start is called before the first frame update
public GameObject mainwand;
public Mainskript1 mainscript;
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended)
{
mainscript.Klickbehandler(1);
print("touch auf 1.te");
}
}
}
and now the controlskript from the plane:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Mainskript1 : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
public void Klickbehandler(int nr)
{
print(nr);
}
void Update()
{
}
}
what’s my failure? many thanks