I’m inside the Joystick script from the CrossPlatformInput package. And I’m trying to call the public Throw function inside my Player script attached to the player object. I have a working reference to the player object but it can’t find the script.
public void OnPointerUp (PointerEventData data) //Called when you relese your finger
{
transform.position = m_StartPos;
UpdateVirtualAxes(m_StartPos);
player.GetComponent<Player>().Throw();
}
Edit:
I made a test script and did the exact same thing, this works totally fine:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class test : MonoBehaviour {
private GameObject player;
void Start () {
player = GameObject.FindWithTag ("Player");
}
void Update () {
player.GetComponent<Player> ().Throw ();
}
}