Answer the question
In order to leave comments, you need to log in
NullReferenceException when starting the project, although everything is fine?
The object is bound, nothing is included in the trigger
public class ShopSlot : MonoBehaviour
{
[SerializeField]
private GameObject shipPrefab;
private MoveShip moveShip;
private void OnTriggerEnter2D(Collider2D coll)
{
moveShip = coll.gameObject.GetComponent<MoveShip>();
moveShip.vector3Slot = new Vector3(gameObject.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z);
}
private void OnTriggerExit2D(Collider2D collision)
{
moveShip.vector3Slot = Vector3.zero;
Debug.Log(moveShip.vector3Slot);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question