Enemy bullets pass through my walls
I've been wanting to make a retro fps game for a long time and now, I finally have time to start it, so i looked up on the internet for tutorials to start understanding its mechanics and I found a whole series containing everything I needed to know. After following it very closely, everything seems to work but one thing. My enemies shoot bullets, those bullets have a 2D circle collider which acts as a trigger, and a rigidbody 2D set to kinematic. My walls have 2D box colliders and yet those bullets pass through the walls like they were nothing!
Here are a couple of screenshots of my scripts and editor:
This is the inspector for my bullet game object:
This is the inspector for my bullet game object's child:
and this is my bullets script:
//Beginning of script// public int damageAmount; public float bulletSpeed = 3f; public Rigidbody2D theRB; private Vector3 direction;
// Start is called before the first frame update
void Start()
{
direction = PlayerController.instance.transform.position - transform.position;
direction.Normalize();
direction = direction * bulletSpeed;
}
// Update is called once per frame
void Update()
{
theRB.velocity = direction * bulletSpeed;
}
private void OnTriggerEnter2D(Collider2D other){
if(other.tag == "Player"){
PlayerController.instance.TakeDamage(damageAmount);
Destroy(gameObject);
}
}
Your answer
Follow this Question
Related Questions
Collision check 0 Answers
Collision With Text 0 Answers
Collider Issue 0 Answers
Unity Collider2D is causing the game object to disappear upon collision? 1 Answer
my colliders don't work properly 2 Answers