Script on raycast or the object being hit?

if I have a raycast firing from one object … and then it hits others… is it possible to get the ray cast to action parts of a script on the hit objects? or does all this need to be done from the script on the object firing the raycast?


Hi @davidj2022 ,

In the script which is doing the raycast, if the result is returned, it also returns the hit entity RaycastResult | PlayCanvas API Reference , if you have a script attached to that entity, you can do something like rayResult.entity.script.myScript.myFunction() to call function for the hit entity.