Exemplo n.º 1
0
    private void DetectGround()
    {
        this.groundDetected = Physics.SphereCast(new Vector3(this.transform.position.x, this.transform.position.y - this.characterController.height / 2 + this.sphereGroundDetectionRadius - this.characterControllerRadiusCompensator, this.transform.position.z),
                                                 this.sphereGroundDetectionRadius,
                                                 Vector3.down,
                                                 out this.lastGroundDetectedInfos,
                                                 4,
                                                 groundLayerMask);


        RaycastHit pmHit;

        if (Physics.SphereCast(this.transform.position, 1f, Vector3.down, out pmHit, 0.5f,
                               groundLayerMask))
        {
            if (pmHit.transform.tag.Contains("PMouvante") && !this.jumping)
            {
                RotatePlateformMovement rpm = pmHit.transform.GetComponentInParent <RotatePlateformMovement>();
                PlateformMovement       pm  = pmHit.transform.GetComponentInParent <PlateformMovement>();

                if (rpm != null)
                {
                    this.plateformeMouvanteDir = rpm.VectorDirecteurPlateforme(this.transform);
                }
                else if (pm != null)
                {
                    this.plateformeMouvanteDir = pm.VectorDirecteurPlateforme();
                }
            }
            else
            {
                this.plateformeMouvanteDir = Vector3.zero;
            }
        }
    }
Exemplo n.º 2
0
    private void CheckPlateformMouvante()
    {
        Collider[] col = Physics.OverlapSphere(this.transform.position, 1f, groundLayerMask);
        foreach (var truc in col)
        {
            Debug.Log(truc.name);
            if (truc.transform.tag.Contains("PMouvante"))
            {
                RotatePlateformMovement test  = truc.gameObject.GetComponentInParent <RotatePlateformMovement>();
                PlateformMovement       test2 = truc.gameObject.GetComponentInParent <PlateformMovement>();

                if (test != null)
                {
                    rpm = test;
                }
                else if (test2 != null)
                {
                    pm = test2;
                    this.plateformPosition = pm.transform.position;
                    if (this.distPlateform == Vector3.zero)
                    {
                        this.distPlateform = this.plateformPosition - this.transform.position;
                    }
                }

                Debug.Log("Find !");
            }

            if (truc == col[col.Length - 1] && rpm == null)
            {
                this.plateformPosition = Vector3.zero;
            }
        }
    }