hi,On collider hit/ raycast do not work when the scene is build as a standalone, any ideas?
I created a new project to test it, i found raycast function is effective when the point is near enough to camera when the scene is built. It’s about in 3 metre . But it’s okay in U3D.
var fireRange : float = 2000;
camRay = cam.ScreenPointToRay(new Vector3(Screen.width * 0.5, Screen.height * 0.5, 0));
if(Physics.Raycast(camRay.origin + camRay.direction * 0.1, camRay.direction, hit, fireRange))
{
printMessage(“Hited!”);
}
When you test does it work when you change the game window in U3D from Free Aspect to Standalone 1024 x 768?
it’s okay now.
the reason is :
function PlayShootSound()
{
// I did not check the shootSound before, but the game can run in Unity3D without it …
if(shootSound != null)
{
audio.PlayOneShot(shootSound);
}
}