Hello, I have created a script that has no errors and everything is properly referenced to it, but it just refuses to do what it is told…
I know this is vague, but it is all I can really say about it: No errors, variables are set and referenced, doesn’t work at all.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bomb : MonoBehaviour
{
public GameObject Explosion;
public GameObject Trigger;
public Rigidbody rb;
public MeshRenderer mr;
public bool ready = false;
void Start() {
rb = GetComponent<Rigidbody>();
Invoke("ResetColl" , 0.05f);
}
private void ResetColl() {
ready = true;
}
public void OnCollisionEnter(Collision bombCollision) {
if (ready) {
Explosion.SetActive(true);
Invoke("EndMovement" , 0.5f);
Invoke("DestroySelf", 3f);
}
}
public void OnCollisionExit() {
ready = false;
}
public void EndMovement() {
rb.constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionY | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
mr.enabled = false;
Trigger.SetActive(true);
}
public void DestroySelf() {
Destroy(gameObject);
}
}