object needs to be in scene from start to be called for ray?

Hi,
my problem is i need object C that is not originally in the scene from the start to be detected by a ray between object A and B

The user places object C into the scene by calling an instantiate function.

if i place object C into my scene from the start, the script works fine, but when i “create” the object while in game, it can not be picked up.

any ideas?

Is it in the same layer you are raycasting in?

yea, i have both objects in layer 9

Hmm, well, it should work. I’m sure you already did but double check to make sure the instantiated object has a collider and that it is activated.

Do you cast on the same frame it is instantiated? Maybe try again a frame later, after C has a chance to run it’s own Update().

yea i have a collider…

the update should automatically be checking every frame after its been placed no? what should i change it to Late? Fixed? guess ill try both? lol

Hmm, no I don’t mean changing to Late, though who knows, maybe that will work… I meant make sure your ray is cast at least one frame after the actual instantiation… it;s possible that the collider isn’t fully initialized until the frame after it is Instantiated. That’s just a guess though.