Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        if (WalkOnOff.GetState(SteamVR_Input_Sources.Any))
        {
            robotAnimation.HandleInput("down w");
        }
        else
        {
            robotAnimation.HandleInput("up w");
        }

        foreach (string key in TrackedKeyUp)
        {
            if (Input.GetKeyDown(key))
            {
                robotAnimation.HandleInput("down " + key);
            }
        }
        foreach (string key in TrackedKeyDown)
        {
            if (Input.GetKeyUp(key))
            {
                robotAnimation.HandleInput("up " + key);
            }
        }
    }
Esempio n. 2
0
    void OnCollisionEnter(Collision cul)
    {
        RobotAnimation controller = gameObject.GetComponent <RobotAnimation>();

        controller.HandleInput("Attack");
        renderer.sharedMaterial = materials[1];
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        RaycastHit hit;
        int        ignoreLayers = ~(1 << 9);

        if (Physics.Raycast(transform.position + 0.3f * Vector3.up, Vector3.down, out hit, 100, ignoreLayers))
        {
            transform.position = hit.point;
            currentSlope       = hit.normal;
        }

        var moveRotation = Quaternion.FromToRotation(Vector3.up, currentSlope) * onlyYRotation(camera.rotation);

        if (controllable && !Trigger.GetState(SteamVR_Input_Sources.Any) && !animator.GetCurrentAnimatorStateInfo(0).IsName("Jump Attack"))
        {
            animator.SetBool("Action", false);
            float horizontal = Joystick.GetAxis(SteamVR_Input_Sources.Any)[0];
            float vertical   = Joystick.GetAxis(SteamVR_Input_Sources.Any)[1];
            this.vertical = vertical;

            var forward = moveRotation * Vector3.forward;
            var right   = moveRotation * Vector3.right;

            transform.position += (vertical * speed * forward);
            transform.position += (horizontal * speed * right);

            if (horizontal < vertical)
            {
                if (vertical < 0f)
                {
                    animationController.HandleInput("Start Walk B");
                    //DisableWalkCycles("WalkBack");
                }
                else if (vertical > 0f)
                {
                    animationController.HandleInput("Start Walk F");
                    //animator.SetBool("WalkForward", true);
                    //DisableWalkCycles("WalkForward");
                }
            }
            else if (horizontal > vertical)
            {
                if (horizontal < 0f)
                {
                    animationController.HandleInput("Start Walk L");
                    //animator.SetBool("WalkLeft", true);
                    //DisableWalkCycles("WalkLeft");
                }
                else if (horizontal > 0f)
                {
                    animationController.HandleInput("Start Walk R");
                    //animator.SetBool("WalkRight", true);
                    //DisableWalkCycles("WalkRight");
                }
            }
            else
            {
                animationController.HandleInput("Stop Walk");
                //DisableWalkCycles();
            }
        }
        else
        {
            animator.SetBool("Action", true);
        }
    }