- Home /
Should I use raycasting or colliders?
Hello,
I have quite a simple question. I am currently working on a project that I wish to put guns/weapons into. Now when it comes down to guns is it preferable to use raycasting to deal damage to enemies or actually instantiate a gameobject "bullet" with a collider on it and have it check to see if it hits the enemy? I've worked with raycasting before so it's very simple to do that method and I've tried the bullet method over a year ago on a short project for school. So I technically know how to accomplish both but which would be the best method to use for a shooter?
Answer by Jeff-Kesselman · Jun 19, 2014 at 12:16 AM
It really depends on the effect you want.
If you want a shot to hit or miss instantaneously, use a ray cast. If you want a shot to take time to hit or miss the target, use an object.
In terms of CPU usage, the ray cast is much more efficient so its generally sued unless trying to actually model something that needs movement dynamics, like a missile.
Your answer
Follow this Question
Related Questions
Raycast from inside an object 2 Answers
Raycast shooting problems 1 Answer
Why do my bullets only destroy themselves sometimes after colliding with the wall? 0 Answers
raycast not doing good 1 Answer