TopDown Engine のキャラクターを、アナログスティックと十字キーの両方で動かせるようにする

CharacterMovement の代わりに、以下のスクリプトをアタッチします。

using System;
using MoreMountains.TopDownEngine;
using UnityEngine;

public class CharacterMovementCustom : CharacterMovement
{
    float secondaryHorizontalInput;
    float secondaryVerticalInput;

    protected override void InternalHandleInput()
    {
        base.InternalHandleInput();

        secondaryHorizontalInput = _inputManager.SecondaryMovement.x;
        secondaryVerticalInput = _inputManager.SecondaryMovement.y;
    }

    protected override void HandleInput()
    {
        if (InputAuthorized)
        {
            _horizontalMovement = Math.Abs(secondaryHorizontalInput) > Mathf.Epsilon
                ? secondaryHorizontalInput
                : _horizontalInput;

            _verticalMovement = Math.Abs(secondaryVerticalInput) > Mathf.Epsilon
                ? secondaryVerticalInput
                : _verticalInput;
        }
        else
        {
            _horizontalMovement = 0f;
            _verticalMovement = 0f;
        }
    }

    public override void ResetInput()
    {
        base.ResetInput();

        secondaryHorizontalInput = 0f;
        secondaryVerticalInput = 0f;
    }
}

The coloring of this site is Dracula PRO🧛🏻‍♂️
This website uses the FontAwesome icons licensed under CC BY 4.0.

2020 GIGA CREATION