コード例 #1
0
    //float isMovingH = 0.0f;
    //float isMovingV = 0.0f;

    void Start()
    {
        input = GameObject.Find("InputManager").GetComponent <InputManager>();

        // initialize my accessor
        myStats = GetComponent <PlayerAccesor>();
        myStats.setDashing(false);
        myStats.setCharging(false);

        // rigid body used for in-engine physics
        rb = GetComponent <Rigidbody>();
        //dashing = false;
        //charging = false;
        animator = GetComponent <Animator>();



        // gravity is intended to be used for this object
        rb.useGravity   = true;
        Physics.gravity = new Vector3(0f, -30.0f, 0f);
    }
コード例 #2
0
    //float isMovingH = 0.0f;
    //float isMovingV = 0.0f;

    void Start() {

        // initialize my accessor
        myStats = GetComponent<PlayerAccesor>();
        myStats.setDashing(false);
        myStats.setCharging(false);

        // rigid body used for in-engine physics 
        rb = GetComponent<Rigidbody>();
        //dashing = false;
		//charging = false;
        animator = GetComponent<Animator>();



		
        // gravity is intended to be used for this object
        rb.useGravity = true;
        Physics.gravity = new Vector3(0f, -30.0f, 0f);

    }
コード例 #3
0
    // Update is called once per frame
    void FixedUpdate()
    {
        //camera setting: get the direction camera is facing.
        Vector3 camDir = PlayerCamera.transform.forward;

        camDir.y = 0;
        camDir.Normalize();

        Vector3 newVel = Vector3.zero;

        if (PM)
        {
            if (Input.GetAxis(DashButton) == 1 && GetComponent <PlayerStamina>().currentStamina > 50)
            {
                myStats.setCharging(true);
                IsCharging = Input.GetAxis(DashButton);
                animate.SetFloat("IsCharging", IsCharging);
            }

            if (Input.GetAxis(DashButton) != 1 && myStats.isCharging() && GetComponent <PlayerStamina>().currentStamina > 50)
            {
                newVel  = Vector3.zero;
                dashDir = camDir;
                myStats.setCharging(false);
                myStats.setDashing(true);


                IsDashing = true;
                animate.SetBool("IsDashing", IsDashing);

                GetComponent <PlayerStamina>().ApplyFatigue(50);
            }
        }

        if (myStats.isCharging() == true)
        {
            transform.rotation = Quaternion.LookRotation(camDir);
        }

        //if (PM.isDashing()) {
        if (myStats.isDashing())
        {
            dashRecovery++;
            newVel             += dashDir * (speed * 3f);
            transform.position += (newVel * Time.fixedDeltaTime);

            //transform camera
            if (newVel != Vector3.zero)
            {
                transform.rotation = Quaternion.LookRotation(dashDir);
            }

            //check if dash is over
            if (dashRecovery >= dashDuration)
            {
                myStats.setDashing(false);
                dashRecovery = 0;
                IsDashing    = false;
                animate.SetBool("IsDashing", IsDashing);
                IsCharging = 0.0f;
                animate.SetFloat("IsCharging", IsCharging);
            }
        }
    }