예제 #1
0
        private void OnAttachedToHand(Hand hand)
        {
            if (activateActionSetOnAttach != null)
            {
                activateActionSetOnAttach.ActivatePrimary();
            }

            if (onAttachedToHand != null)
            {
                onAttachedToHand.Invoke(hand);
            }

            attachedToHand = hand;
        }
예제 #2
0
        protected override void Update()
        {
            base.Update();

            if (attachedToHand)
            {
                if (!was_attached)
                {
                    actionSet.ActivatePrimary();
                }
            }
            else
            {
                if (was_attached)
                {
                    actionSet.Deactivate();
                }
            }
            was_attached = attachedToHand != null;


            if (attachedToHand)
            {
                hand = attachedToHand.handType;
                Vector2 m = a_move.GetAxis(hand);
                movement = new Vector3(m.x, 0, m.y);

                jump = a_jump.GetStateDown(hand);
                glow = Mathf.Lerp(glow, a_jump.GetState(hand) ? 1.5f : 1.0f, Time.deltaTime * 20);
            }
            else
            {
                movement = Vector2.zero;
                jump     = false;
                glow     = 0;
            }

            Joystick.localPosition = movement * joyMove;

            float rot = transform.eulerAngles.y;

            movement = Quaternion.AngleAxis(rot, Vector3.up) * movement;

            jumpHighlight.sharedMaterial.SetColor("_EmissionColor", Color.white * glow);

            character.Move(movement * 2, jump);
        }
예제 #3
0
    private void Update()
    {
        if (interactable.attachedToHand == null || crushable == false)
        {
            return;
        }

        if (setToActivate.IsActive() == false)
        {
            setToActivate.ActivatePrimary();
        }

        SteamVR_Input_Sources hand = interactable.attachedToHand.handType;

        float squeeze = actionSqueeze.GetAxis(hand);

        foreach (Renderer rend in renderers)
        {
            rend.material.SetColor("_EmissionColor", (glowColor * Mathf.Pow(squeeze * 2.5f, 2)));
        }

        bool crush = actionCrush.GetStateDown(hand);

        if (crush)
        {
            Instantiate(BrokenPrefab, transform.position, Quaternion.identity);
            Destroy(gameObject);
        }
        else
        {
            float stress = Mathf.Pow(squeeze, 2);

            if (squeeze > 0.3f)
            {
                interactable.attachedToHand.TriggerHapticPulse((ushort)Mathf.Lerp(200, 1000, squeeze * 2));
            }

            Vector3 shake = new Vector3(Random.Range(-shakingAmount, shakingAmount), Random.Range(-shakingAmount, shakingAmount), Random.Range(-shakingAmount, shakingAmount));
            shake *= stress;
            rigidbody.AddForce(shake * 20000, ForceMode.Impulse);
        }
    }
예제 #4
0
 // Start is called before the first frame update
 void Start()
 {
     character_controller = GetComponent <CharacterController>();//キャラクターコントローラー取得
     myAction.ActivatePrimary(true);
 }
예제 #5
0
        protected override void Update()
        {
            base.Update();
            Vector2 steer    = Vector2.zero;
            float   throttle = 0;
            float   brake    = 0;

            bool reset = false;

            bool b_brake = false;
            bool b_reset = false;


            if (attachedToHand)
            {
                SteamVR_Input_Sources hand = attachedToHand.handType;

                if (!was_attached)
                {
                    actionSet.ActivatePrimary();
                }


                steer    = a_steering.GetAxis(hand);
                throttle = a_trigger.GetAxis(hand);
                b_brake  = a_brake.GetState(hand);
                b_reset  = a_reset.GetState(hand);
                brake    = b_brake ? 1 : 0;
                reset    = a_reset.GetStateDown(hand);
            }
            else
            {
                if (was_attached)
                {
                    actionSet.Deactivate();
                }
            }
            was_attached = attachedToHand != null;


            if (reset && resettingRoutine == null)
            {
                resettingRoutine = StartCoroutine(DoReset());
            }

            if (ui_Canvas != null)
            {
                ui_Canvas.gameObject.SetActive(attachedToHand);

                usteer = Mathf.Lerp(usteer, steer.x, Time.deltaTime * 9);
                ui_steer.localEulerAngles = Vector3.forward * usteer * -ui_steerangle;
                ui_rpm.fillAmount         = Mathf.Lerp(ui_rpm.fillAmount, Mathf.Lerp(ui_fillAngles.x, ui_fillAngles.y, throttle), Time.deltaTime * 4);
                float speedLim = 40;
                ui_speed.fillAmount = Mathf.Lerp(ui_fillAngles.x, ui_fillAngles.y, 1 - (Mathf.Exp(-buggy.speed / speedLim)));
            }


            modelJoystick.localRotation = joySRot;

            /*if (input.AttachedHand != null && input.AttachedHand.IsLeft)
             * {
             *  Joystick.Rotate(steer.y * -joystickRot, steer.x * -joystickRot, 0, Space.Self);
             * }
             * else if (input.AttachedHand != null && input.AttachedHand.IsRight)
             * {
             *  Joystick.Rotate(steer.y * -joystickRot, steer.x * joystickRot, 0, Space.Self);
             * }
             * else*/
            //{
            modelJoystick.Rotate(steer.y * -joystickRot, steer.x * -joystickRot, 0, Space.Self);
            //}

            modelTrigger.localRotation = trigSRot;
            modelTrigger.Rotate(throttle * -triggerRot, 0, 0, Space.Self);
            buttonBrake.localScale = new Vector3(1, 1, b_brake ? 0.4f : 1.0f);
            buttonReset.localScale = new Vector3(1, 1, b_reset ? 0.4f : 1.0f);

            buggy.steer               = steer;
            buggy.throttle            = throttle;
            buggy.handBrake           = brake;
            buggy.controllerReference = transform;
        }
예제 #6
0
 private void Interactable_onAttachedToHand(Hand hand)
 {
     actionSet.ActivatePrimary();
 }
예제 #7
0
 private void Interactable_onAttachedToHand(Hand hand)
 {
     setToActivate.ActivatePrimary();
 }