I am trying to make a grappling hook in Unity. it works fine on stationary objects, but the raycast doesn’t work with objects that are animated, have scripts moving them, or have a rigidbody. When I try to view their properties during run-time using a breakpoint, it says all the components are “depreciated”. I have tried getting the object from the raycast hit, I have tried getting the object from a parent object and a child object, I have tried getting an object using its components, and I have tried getting the object with GetComponent<> and FindComponent<>. So far nothing has worked.
Raycast is working and you are doing something wrong.
Try with something simple, just make raycast from point in world space to particular direction, move your object to make the intersection with the ray.
That may be an observed characteristic but that is not the problem.
Remember in Unity only ONE THING moves at a time, the thing you are moving.
Even things with Rigidbodies or Animations are absolutely positively 100% FROZEN in place except when the piece of code (Physic system or animation system) moves it.
My guess is one of the standard raycasting fails:
you are casting from the wrong spot
you are casting in the wrong direction
the object you think you can hit doesn’t have a collider
you are mis-calling Raycast (see below)
you are starting from within the object
you are not casting far enough
you have a layer misconfigured
etc.
Use Physics.Raycast() always with named arguments because it contains many poorly-designed overloads: