hi people of earth. what I am trying to do is have my projectile/ bullet (paint ball) hit the wall play a splat animation and delete. so far it is hitting the wall and being destroyed when I try and turn on the animator through a script it gives me a error when I’m in the middle of the game this is the error. NullReferenceException: Object reference not set to an instance of an object
splat.OnCollisionEnter (UnityEngine.Collision col) (at Assets/C#/splat.cs:15)and these are my scripts the first is for actually shooting (goes into the spawn object) and the second is the one where on hitting the wall or ground it is supposed to splat and delete. please tell me what I am doing wrong.
number 1:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class shoot : MonoBehaviour {
public Rigidbody projectile;
public float speed;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetButtonDown ("x")) {
Rigidbody instantiatedProjectile = Instantiate (projectile, transform.position, transform.rotation) as Rigidbody;
instantiatedProjectile.velocity = transform.TransformDirection (new Vector3 (0, speed, 0));
}
}
}
and number 2:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class splat : MonoBehaviour {
private Animator A;
float bulletlife = 7f;
void start (){
A = GetComponent <Animator> ();
A.enabled = false;
}
void OnCollisionEnter (Collision col){
A.enabled = true;
StartCoroutine(splatseconds());
}
IEnumerator splatseconds () {
yield return new WaitForSeconds (2f);
Destroy(gameObject);
}
void Update () {
Destroy(gameObject,bulletlife);
}
}