Beispiel #1
0
    void UpdateTmpTrap()
    {
        if (tmpTrap == null)
        {
            // create tmp trap if not trap exist
            tmpTrap = Instantiate(tmpTrapPrefab);
        }
        trapRay.origin    = cam.transform.position;
        trapRay.direction = cam.transform.forward;
        // raycast to floor mask
        if (Physics.Raycast(trapRay, out trapHit, float.MaxValue, floorMask))
        {
            Vector3 hitPoint = trapHit.point;
            tmpTrap.transform.position = GameUtility.GetRoundVector3(hitPoint);

            // check if trap position is valid
            if (trapManager.CheckValidTrapPoint(hitPoint))
            {
                validTmpTrapFlag = true;
                tmpTrap.GetComponent <MeshRenderer>().material = tmpTrapMaterial;
            }
            else
            {
                validTmpTrapFlag = false;
                tmpTrap.GetComponent <MeshRenderer>().material = tmpInvalidTrapMaterial;
            }
        }
    }