例子一:
该脚本时绑在main Camera上的,"/Scene/player"这是在Hierarchy目录下直接找寻Scene
if (Physics.Raycast (ray.origin, ray.direction, hit, 10 )) { if (hit.transform.name == " player " ){ var player = transform.Find( " /Scene/player " ); print (player.position); }
例子二: 该脚本时绑在main Camera上的,"Scene/player"这是在main Camera目录下直接找寻Scene
if (Physics.Raycast (ray.origin, ray.direction, hit, 10 )) { if (hit.transform.name == " player " ){ var player = transform.Find( " Scene/player " ); print (player.position); }