i can’t get this collision detection to work, heres my script:
using UnityEngine;
using System.Collections;
public class movement : MonoBehaviour {
public int accSpeed;
public Vector3 force;
private Vector3 spawn;
public GameObject die;
void Start (){
spawn = transform.position;
}
void Update () {
force = new Vector3 (Input.GetAxis ("Horizontal"), 0, Input.GetAxis ("Vertical"));
rigidbody.AddForce (force * accSpeed);
}
void OnCollisionStay(Collision other){
if (other.transform.tag == "enemy") {
Instantiate (die, transform.position, Quaternion.identity);
transform.position = spawn;
}
}
}
/edit i just noticed im using OnCollisionStay but it dosnt work wit either
/edit2 more info
I have read that the collider sometimes needs a rigid body which i have, and has the isKinnematic trigger on. I dont want IsTrigger because then it wont collide.