Hi everyone so I´m having this error on my console and I don´t really now what it means I´m new to this so that´s the reason I´m here. So I have some ladders to climb and I have a roll ability and when I roll and enter a ladder this pops up.
NullReferenceException: Object reference not set to an instance of an object Ladders.OnTriggerStay2D (UnityEngine.Collider2D collision) (at Assets/Scripts/Interactables/Ladders.cs:26)
so now here´s my ladders script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Ladders : MonoBehaviour
{
private GatherInput gI;
private PlayerMoveControls pMC;
//private Shoot shoot;
void Start()
{
}
private void OnTriggerEnter2D(Collider2D collision)
{
gI = collision.GetComponent<GatherInput>();
pMC = collision.GetComponent<PlayerMoveControls>();
//shoot = collision.GetComponent<Shoot>();
}
private void OnTriggerStay2D(Collider2D collision)
{
if(gI.tryToClimb)
{
pMC.onLadders = true;
//shoot.enabled = false;
}
}
private void OnTriggerExit2D(Collider2D collision)
{
pMC.ExitLadders();
//shoot.enabled = true;
}
}
can anyone help me on how to solve this ?? now I have to mention that everything is working fine while playing the game all the abilities and animations everything is ok but I do get that error. thank you very much