Answer the question
In order to leave comments, you need to log in
Writes NullReferenceException: Object reference not set to an instance of an object Platform. What to do>?
Script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Platform : MonoBehaviour
{
public float forceJump;
public void OnCollisionEnter2D(Collision2D collision)
{
if (collision.relativeVelocity.y < 0)
{
Doodle.instance.DoodleRigid.velocity = Vector2.up * forceJump;
}
}
}
Answer the question
In order to leave comments, you need to log in
NullReferenceException this error in 99% of cases means that you are accessing an object that is empty (null). Basically, this means that it is not tightened where it should be. BUT! In this case, the compiler writes that on line 13 you are accessing an object that is null. Most likely there is no rigidbody2d on this object or there is no access to it. To find errors, I recommend reading the logs and using Debug.Log();
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question