コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        Vector3 inputAxis = Vector3.zero;

        inputAxis.x = Input.GetAxis("Horizontal");
        inputAxis.z = Input.GetAxis("Vertical");

        target.Roll(inputAxis);
    }
コード例 #2
0
    void UpdateRollable(Vector3 moveDir)
    {
        if (!rollable)
        {
            return;
        }



        if (rollable.IsRolling() == false)
        {
            startRollPoint = rollable.transform.position;

            startRollPoint       = new Vector3(
                startRollPoint.x = (int)((startRollPoint.x + (startRollPoint.x >= 0 ? 0.5f : -0.5f)) / 1.0f) * 1.0f,
                startRollPoint.y = (int)((startRollPoint.y + (startRollPoint.y >= 0 ? 0.5f : -0.5f)) / 1.0f) * 1.0f,
                startRollPoint.z = (int)((startRollPoint.z + (startRollPoint.z >= 0 ? 0.5f : -0.5f)) / 1.0f) * 1.0f);


            Vector3 playerPos = transform.position;
            playerPos.y = startRollPoint.y;

            playerPos       = new Vector3(
                playerPos.x = (int)((playerPos.x + (playerPos.x >= 0 ? 0.5f : -0.5f)) / 1.0f) * 1.0f,
                playerPos.y = (int)((playerPos.y + (playerPos.y >= 0 ? 0.5f : -0.5f)) / 1.0f) * 1.0f,
                playerPos.z = (int)((playerPos.z + (playerPos.z >= 0 ? 0.5f : -0.5f)) / 1.0f) * 1.0f);


            Vector3    dirToTarget = playerPos - startRollPoint;
            EDirection rollDir     = dirToTarget.ToDir();


            endRollPoint = playerPos;
        }

        if (rollable.IsRolling() == false)
        {
            rollable.Roll(endRollPoint - startRollPoint);
        }

        rollable.ForceUpdateCall();

        KeepInBlockBounds();
    }