How can I use RayCasting to interact with RigidBodies and Colliders?
I'm making a first person shooter, and I'm using RayCasting for the shooting system. I actually have two gun objects, one's a model, which plays a sound effect and an animation when I click the shoot button (the left mouse button), and the other one is an empty GameObject which has a script attached to it, it sends a RayCast which sends a message which calls a function called "ApplyDamage" so when it hits an enemy, it can damage them. I want it to interact with RigidBodies, so when I shoot them, they fall over, but I heard that that isn't possible (I think), so maybe there's an alternative way, like making the object move in the direction from where the RayCast hits it. Other than that, is there a way to make a RayCast interact with colliders, like if it collides with a brick or a wall, it makes a hole in it?
Raycasts don't interact with anything in the scene, all they do is return data about a collider along the path of the ray. All results of the raycast have to be done by code. You can use the point of the hit to calculate forces to apply if you want things like the target spinning when hit near an edge. Putting a hole in a wall would probably require either a model made up of many smaller pieces that can be disabled/removed, or a dynamic mesh system.
I checked out the link you sent me and fortunately, IT WOR$$anonymous$$ED :D, thanks a lot :), I've been trying to do this for days.