Collision Detection for fast moving game object in Unity

Wil Prim

I am working on building a basic space shooter game but am having trouble with a trigger collider.

In the game, I have a Bullet prefab that has a Capsule Trigger Collider attached to it and the enemy is right now a basic cube with a box collider attached to it.

When I run the game I start shooting the bullets and the Enemy cube doesn't disappear until after a few shots.

Here is my code for the bullet prefab:

void OnTriggerEnter(Collider col) {
        if (col.tag == "Enemy") {
            Destroy (col.gameObject);
        }
    }

And a screenshot of my Attributes of each game object:

Bullet Prefab:

Bullet Prefab

And here is the enemy cube:

enter image description here

Here is a link to a video of what is happening...

https://youtu.be/NjHK6oVP0OQ

Wil Prim

I understand that this question may be similar to the one posted in the comments however I did find another solution that may be of some use to people who have this exact issue.

The error was occurring because my "Bullet" prefab was moving so fast that it wasn't able to detect a collision.

Fix: I changed the Collision Detection property of the Bullet prefabs Rigidbody to Continuous Dynamic because it is moving fast. Full reference to Rigidbody Collision Detection Modes the link is below.

enter image description here

https://docs.unity3d.com/ScriptReference/Rigidbody-collisionDetectionMode.html

The difference between this and the "similar" question's answer posted in the comments is that answer has a lot to do with Raycasting versus very simple colliders (which is more of what I was looking for).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Collision Detection between a moving and non-moving object

From Dev

Collision Detection between a moving and non-moving object

From Dev

Moving platform collision detection

From Dev

Collision detection in javascript game

From Dev

Javascript Canvas Game - Collision Detection

From Dev

Game character is moving too fast

From Dev

Java detect collision for fast moving objects

From Dev

Tkinter in python - object detection (not collision)

From Dev

Collision detection in java 2d game

From Dev

Collision detection in javascript canvas tanks game

From Dev

Java Game Physics - Determine intersection and collision detection

From Dev

Trying to use quadtrees for collision detection in a game

From Dev

Game score via collision detection increment

From Dev

Trying to use quadtrees for collision detection in a game

From Dev

Problem with collision detection is JS canvas game

From Dev

Collision detection not working in Unity 2D

From Dev

Unity 2d collision detection not registering

From Dev

Unity 2D Collision Detection

From Dev

Are There Alternatives to Collision Detection in Unity3D?

From Dev

Small Game Lag On Really Fast Moving Player

From Dev

Unity: Player Death on object collision

From Dev

2D moving object collision

From Dev

Inelastic collision only moving object to the right

From Dev

How to get collision detection of a rotating object in libgdx

From Dev

HTML Canvas game: 2D collision detection

From Dev

game viewport focus vs collision detection on y axis against gravity

From Dev

Collision detection in 2D game without tiles XNA

From Dev

Collision Detection in FPS Game using three.js

From Dev

if statement in JavaScript game not working as desired to allow for collision detection

Related Related

  1. 1

    Collision Detection between a moving and non-moving object

  2. 2

    Collision Detection between a moving and non-moving object

  3. 3

    Moving platform collision detection

  4. 4

    Collision detection in javascript game

  5. 5

    Javascript Canvas Game - Collision Detection

  6. 6

    Game character is moving too fast

  7. 7

    Java detect collision for fast moving objects

  8. 8

    Tkinter in python - object detection (not collision)

  9. 9

    Collision detection in java 2d game

  10. 10

    Collision detection in javascript canvas tanks game

  11. 11

    Java Game Physics - Determine intersection and collision detection

  12. 12

    Trying to use quadtrees for collision detection in a game

  13. 13

    Game score via collision detection increment

  14. 14

    Trying to use quadtrees for collision detection in a game

  15. 15

    Problem with collision detection is JS canvas game

  16. 16

    Collision detection not working in Unity 2D

  17. 17

    Unity 2d collision detection not registering

  18. 18

    Unity 2D Collision Detection

  19. 19

    Are There Alternatives to Collision Detection in Unity3D?

  20. 20

    Small Game Lag On Really Fast Moving Player

  21. 21

    Unity: Player Death on object collision

  22. 22

    2D moving object collision

  23. 23

    Inelastic collision only moving object to the right

  24. 24

    How to get collision detection of a rotating object in libgdx

  25. 25

    HTML Canvas game: 2D collision detection

  26. 26

    game viewport focus vs collision detection on y axis against gravity

  27. 27

    Collision detection in 2D game without tiles XNA

  28. 28

    Collision Detection in FPS Game using three.js

  29. 29

    if statement in JavaScript game not working as desired to allow for collision detection

HotTag

Archive