- Home /
Self resolved issue.
problem with collision detection
my scene is, my player shoots prefab (bullet) and when it hits an object with tag name blocks the prefab has to get destroyed.i ahve added rigid body component for the prefab and checked on istrigger on another object which is in the bullet's path. the problem is i dont see any collision detection when the bullet hits any object that has tag name blocks. the script is as follows.
using UnityEngine; using System.Collections;
public class projectile : MonoBehaviour {
public float projectileSpeed = 2f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update ()
{
float amtToMove = projectileSpeed * Time.deltaTime;
transform.Translate(Vector3.right * amtToMove);
}
void OnTriggerEnter(Collider otherobject)
{
if(otherobject.tag == "blocks")
{
Debug.Log("iam hit");
}
}
}
need help...
For any fast moving rigidbody, set collision detection to ContinuousDynamic. For any rigidbodies this bullet will be hitting, set to Continuous.
$$anonymous$$ore information on Collision Detection $$anonymous$$ode HERE
YA THAN$$anonymous$$ YOU THE PROBLE$$anonymous$$ GOT SOLVED.THE PROBLE$$anonymous$$ WAS I ADDED RIGID BODY TO THE PREFAB AND DIDN'T CHEC$$anonymous$$ OFF IS$$anonymous$$INE$$anonymous$$ATICS.
As a future reference: If you solve a problem on your own, please post your resolution as an answer so that others can see the solution. Then close the question, so that people like me don't try to answer it, then bug you about it lol.