Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RaycastHit _hit; if statement not working #23

Open
IpanTheWrongWay opened this issue Mar 4, 2018 · 1 comment
Open

RaycastHit _hit; if statement not working #23

IpanTheWrongWay opened this issue Mar 4, 2018 · 1 comment

Comments

@IpanTheWrongWay
Copy link

Sometime between episode 12 and 13, my Raycast stopped detecting hits. Any idea what is happening?

Below is the Shoot(); I added debug.logs to find the error.

[Client]
void Shoot()
{
if (!isLocalPlayer)
{
return;
}

    //WE ARE SHOOTING, CALL THE ONSHOOT METHOD ON THE SERVER
    CmdOnShoot();

    RaycastHit _hit;
    if (Physics.Raycast(cam.transform.position, cam.transform.forward, out _hit, currentWeapon.range, mask))
    {
        Debug.Log("RaycastHit"); //DID NOT PLAY
        if (_hit.collider.tag == PLAYER_TAG)
        {
            CmdPlayerShot(_hit.collider.name, currentWeapon.damage);
        }

        //we hit something call the on hit method ont the server
        Debug.Log("raycasthit"); //DID NOT PLAY
        CmdOnHit(_hit.point, _hit.normal);
    }
    else
    {
        Debug.Log("nohit"); //DID PLAY
    }     
}
@IpanTheWrongWay
Copy link
Author

ugh....

On player prefab, the mask was set to only Weapon, instead of everything but localPlayer and Weapon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant