Hello,
How can I solve this error? I already searched it in google and in other webstites,but I still don´t know how to fix it.
NullReferenceException: Object reference not set to an instance of an object
ParedRompible.Romper () (at Assets/Scripts/Player/ParedRompible.cs:35)
This is the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ParedRompible : MonoBehaviour
{
[SerializeField] private float vida;
private Explodable _explodable;
private void Start()
{
_explodable = GetComponent<Explodable>();
}
public void TomarDaño(float daño)
{
vida -= daño;
if (vida <= 0)
{
Romper();
}
}
private void Romper()
{
_explodable.explode();
ExplosionForce ef = GameObject.FindObjectOfType<ExplosionForce>();
ef.doExplosion(transform.position);
Debug.Log("hola");
}
}
Thanks for your time;