Answer the question
In order to leave comments, you need to log in
Why does Unity3D get NullReferenceException: Object reference not set to an instance of an object?
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.GetComponent<SpawnDestroyWall>().speed > 20 && other.tag == "Wall")
{
other.gameObject.GetComponent<SpawnDestroyWall>().Spawn();
}
if (other.gameObject.GetComponent<DestroyWallSpeed>().speed > 20 && other.tag == "WallParticl")
{
if (!other.gameObject.GetComponent<Rigidbody>())
{
other.gameObject.AddComponent<Rigidbody>();
Destroy(other, 20);
}
}
}
private void OnTriggerEnter(Collider other)
{
if (other.tag == "Wall" && moveSpeed > 10)
{
other.gameObject.GetComponent<SpawnDestroyWall>().Spawn();
Destroy(other, 20);
}
if (other.tag == "WallParticl" && moveSpeed > 10)
{
if (!other.gameObject.GetComponent<Rigidbody>())
{
other.gameObject.AddComponent<Rigidbody>();
Destroy(other, 20);
}
}
}
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