Collision events and raycasters

Ok. I’m trying to wrap my head around something. I want two objects to to intersect and have them change colors. When they move apart I want them to go back to their original colors. Each object has a timeline animation moving them. I am thinking raycaster with interactenter and intersect leave events. Would I attach the raycaster to one or both of the objects intersecting?
I’m struggling with the raycaster outside of setting it to Any help from anyone would be great. Thanks.


I think for what you are trying to do you would want to use a trigger zone, place that onto one of the objects. A ray caster, no matter where it’s origin is attached, will continue forward, and only forward. The problem with trigger zones is that they will only send messages color if the CENTER of one of the objects enters the trigger zone of the other. But it would be a good place to start.

Also if you know when or where on the timeline the objects will meet, you can always make the color change part of their animations. If you don’t, another thing you could do, is check their positions every frame using the distance formula, and change their color once they are less than a distance that is relatively where the objects should be colliding.

Thanks for pointing me in the right direction. I’ll take a look at trigger regions.

This tutorial helped me a lot!

Transitioning Photospheres