public override void Update()
        {
            if (this.character)
            {
                this.character.characterLocomotion.overrideFaceDirection = (
                    CharacterLocomotion.OVERRIDE_FACE_DIRECTION.GroundPlaneCursor
                    );
            }

            Camera camera    = HookCamera.Instance.Get <Camera>();
            Ray    cameraRay = camera.ScreenPointToRay(Input.mousePosition);

            QueryTriggerInteraction query = QueryTriggerInteraction.Ignore;

            if (Physics.RaycastNonAlloc(cameraRay, buffer, Mathf.Infinity, -1, query) > 0)
            {
                this.aimToVector = buffer[0].point;
            }

            WeaponMuzzle muzzle = this.GetMuzzle();

            this.pointShootingRaycast = muzzle.GetPosition();
            this.pointShootingWeapon  = muzzle.GetPosition();

            float angle = this.GetPitch((this.aimToVector - this.pointShootingWeapon).normalized);

            this.shooter.SetPitch(angle);
        }
示例#2
0
        public override void Update()
        {
            WeaponMuzzle muzzle = this.GetMuzzle();

            this.pointShootingRaycast = muzzle.GetPosition();
            this.pointShootingWeapon  = muzzle.GetPosition();

            this.shooter.SetPitch(0f);
            this.aimToVector = muzzle.GetDirection() * this.shooter.currentAmmo.distance;
        }
        public override void Update()
        {
            if (this.character)
            {
                this.character.characterLocomotion.overrideFaceDirection = (
                    CharacterLocomotion.OVERRIDE_FACE_DIRECTION.CameraDirection
                    );
            }

            Vector3 cameraForward = HookCamera.Instance.transform.TransformDirection(Vector3.forward);

            float angle = this.GetPitch(cameraForward);

            this.shooter.SetPitch(angle);

            WeaponMuzzle muzzle = this.GetMuzzle();

            this.pointShootingWeapon  = muzzle.GetPosition();
            this.pointShootingRaycast = HookCamera.Instance.transform.position;

            this.aimToVector = cameraForward;
        }
示例#4
0
        public override void Update()
        {
            if (this.character)
            {
                this.character.characterLocomotion.overrideFaceDirection = (
                    CharacterLocomotion.OVERRIDE_FACE_DIRECTION.GroundPlaneCursor
                    );
            }

            Camera camera    = HookCamera.Instance.Get <Camera>();
            Ray    cameraRay = camera.ScreenPointToRay(Input.mousePosition);

            Plane plane = new Plane(Vector3.up, this.shooter.transform.position);

            Vector3 direction = Vector3.zero;
            float   rayDistance;

            if (plane.Raycast(cameraRay, out rayDistance))
            {
                Vector3 cursor = cameraRay.GetPoint(rayDistance);
                Vector3 target = Vector3.MoveTowards(this.shooter.transform.position, cursor, 1f);
                direction = target - this.shooter.transform.position;
                direction.Scale(new Vector3(1, 0, 1) * 10f);
            }

            WeaponMuzzle muzzle = this.GetMuzzle();

            this.pointShootingRaycast = muzzle.GetPosition();
            this.pointShootingWeapon  = muzzle.GetPosition();

            this.aimToVector = direction.normalized * this.shooter.currentAmmo.distance;
            Vector3 aimTargetPosition = muzzle.GetPosition() + this.aimToVector;

            float angle = this.GetPitch(aimTargetPosition);

            this.shooter.SetPitch(angle);
        }
        public override void Update()
        {
            Camera camera = HookCamera.Instance.Get <Camera>();

            Ray       cursorFromCameraRay = camera.ScreenPointToRay(Input.mousePosition);
            Transform shooterPosition     = this.shooter.transform;

            Plane plane = default(Plane);
            float rayDistance;

            WeaponMuzzle muzzle = this.GetMuzzle();

            this.pointShootingRaycast = muzzle.GetPosition();
            this.pointShootingWeapon  = muzzle.GetPosition();

            switch (this.coordinates)
            {
            case Coordinates.XY:
                plane = new Plane(Vector3.forward, shooterPosition.position);
                this.pointShootingRaycast = new Vector3(
                    this.pointShootingRaycast.x,
                    this.pointShootingRaycast.y,
                    shooterPosition.position.z
                    );
                break;

            case Coordinates.YZ:
                plane = new Plane(Vector3.right, shooterPosition.position);
                this.pointShootingRaycast = new Vector3(
                    shooterPosition.position.x,
                    this.pointShootingRaycast.y,
                    this.pointShootingRaycast.z
                    );
                break;
            }

            Vector3 aimDirection = muzzle.GetDirection();

            if (plane.Raycast(cursorFromCameraRay, out rayDistance))
            {
                Vector3 cursor = cursorFromCameraRay.GetPoint(rayDistance);
                aimDirection = cursor - this.pointShootingRaycast;
            }

            float angle = this.GetPitch(aimDirection);

            this.shooter.SetPitch(angle);
            this.aimToVector = aimDirection.normalized * this.shooter.currentAmmo.distance;

            if (this.character)
            {
                this.character.characterLocomotion.overrideFaceDirection = (
                    CharacterLocomotion.OVERRIDE_FACE_DIRECTION.Target
                    );

                switch (this.coordinates)
                {
                case Coordinates.XY:
                    Vector3 targetPositionXY = (
                        this.shooter.transform.position +
                        (aimDirection.x > 0f ? Vector3.right : Vector3.left)
                        );

                    TargetPosition xyFace = new TargetPosition(TargetPosition.Target.Position);
                    xyFace.targetPosition = targetPositionXY;
                    this.character.characterLocomotion.overrideFaceDirectionTarget = xyFace;
                    break;

                case Coordinates.YZ:
                    Vector3 targetPositionYZ = (
                        this.character.transform.position +
                        (aimDirection.z > 0f ? Vector3.forward : Vector3.back)
                        );

                    TargetPosition yzFace = new TargetPosition(TargetPosition.Target.Position);
                    yzFace.targetPosition = targetPositionYZ;

                    this.character.characterLocomotion.overrideFaceDirection = (
                        CharacterLocomotion.OVERRIDE_FACE_DIRECTION.Target
                        );
                    this.character.characterLocomotion.overrideFaceDirectionTarget = yzFace;
                    break;
                }
            }
        }