Exemplo n.º 1
0
    private void SetupGameplay()
    {
        InputActionMap gameplay = pi.FindActionMap("Gameplay");

        //2D Vectors
        IA_Movement            = gameplay.FindAction("Movement");
        IA_Movement.performed += ctx => Movement = ctx.ReadValue <Vector2>();

        //Toggle Input
        IA_Pause            = gameplay.FindAction("Pause");
        IA_Pause.performed += ctx => Pause = !Pause;

        //Hold Down Input
        IA_Jump            = gameplay.FindAction("Jump");
        IA_Jump.performed += ctx => Jump = true;
        IA_Jump.canceled  += ctx => Jump = false;

        IA_Interact            = gameplay.FindAction("Interact");
        IA_Interact.performed += ctx => Interact = true;
        IA_Interact.canceled  += ctx => Interact = false;

        IA_FlipCamera = gameplay.FindAction("FlipCamera");

        IA_FlipCamera.performed += ctx => flipCamera = true;
        IA_FlipCamera.canceled  += ctx => flipCamera = false;
    }
Exemplo n.º 2
0
 void Awake()
 {
     m_PlayerInput      = GetComponent <PlayerInput>();
     m_ActionMap        = m_PlayerInput.actions.FindActionMap("Player");
     m_MousePressAction = m_ActionMap.FindAction("MousePress");
     m_FuckUnityAction  = m_ActionMap.FindAction("FuckUnity");
 }
Exemplo n.º 3
0
    void Start()
    {
        anim        = GetComponent <Animator>();
        transform   = GetComponent <Transform>();
        playerInput = GetComponent <PlayerInput>();

        //ActionMap 추출
        mainActionMap = playerInput.actions.FindActionMap("PlayerActions");

        //Move, Attack 액션 추출
        moveAction   = mainActionMap.FindAction("Move");
        attackAction = mainActionMap.FindAction("Attack");

        //Move 액션의 performed 이벤트 연결
        moveAction.performed += ctx => {
            Vector2 dir = ctx.ReadValue <Vector2>();
            moveDir = new Vector3(dir.x, 0, dir.y);
            //Warrior_Run 애니메이션 실행
            anim.SetFloat("Movement", dir.magnitude);
        };
        //Move 액션의 canceled 이벤트 연결
        moveAction.canceled += ctx => {
            moveDir = Vector3.zero;
            //Warrior_Run 애니메이션 정지
            anim.SetFloat("Movement", 0.0f);
        };

        //Attack 액션의 performed 이벤트 연결
        attackAction.performed += ctx => {
            Debug.Log("Attack by c# event");
            anim.SetTrigger("Attack");
        };
    }
Exemplo n.º 4
0
 public void OnReturnToDebugRoot(InputAction.CallbackContext context)
 {
     if (context.phase == InputActionPhase.Started)
     {
         //Save handling settings
         PlayerPrefs.SetInt("DAS", das);
         PlayerPrefs.SetInt("ARR", arr);
         PlayerPrefs.SetFloat("SDG", sdg);
         PlayerPrefs.SetInt("rotateDCD", rotateDCD);
         PlayerPrefs.SetInt("harddropDCD", harddropDCD);
         PlayerPrefs.SetInt("holdDCD", holdDCD);
         PlayerPrefs.SetInt("interruptDAS", DASinterruption ? 1 : 0);  //A somewhat odd way of typcasting an int to a bool...
         //Save keybinds
         PlayerPrefs.SetString("keyLeft", map.FindAction("Shift left").bindings[0].effectivePath);
         PlayerPrefs.SetString("keyRight", map.FindAction("Shift right").bindings[0].effectivePath);
         PlayerPrefs.SetString("keySoftDrop", map.FindAction("Soft drop").bindings[0].effectivePath);
         PlayerPrefs.SetString("keyHardDrop", map.FindAction("Hard drop").bindings[0].effectivePath);
         PlayerPrefs.SetString("keyCW", map.FindAction("Rotate CW").bindings[0].effectivePath);
         PlayerPrefs.SetString("keyCCW", map.FindAction("Rotate CCW").bindings[0].effectivePath);
         PlayerPrefs.SetString("key180", map.FindAction("Rotate 180").bindings[0].effectivePath);
         PlayerPrefs.SetString("keyHold", map.FindAction("Hold").bindings[0].effectivePath);
         PlayerPrefs.SetString("keyPause", map.FindAction("Pause").bindings[0].effectivePath);
         PlayerPrefs.SetString("keyReset", map.FindAction("Reset").bindings[0].effectivePath);
         PlayerPrefs.Save();
         //Load scene
         SceneManager.LoadScene("DebugScenes/DebugRoot");
     }
 }
    public static void setControlScheme(string name)
    {
        instance.actionMap = (actionMapNames)Enum.Parse(typeof(actionMapNames), name);
        if (instance.controls.asset != null)
        {
            foreach (InputActionMap actionMap in instance.controls.asset.actionMaps)
            {
                actionMap.Disable();
            }
        }

        InputActionMap input = instance.controls.asset.FindActionMap(name);

        input.Enable();

        axisStates = new List <AxisState>();
        axisStates.Add(new AxisState("Dpad"));

        keyStates = new List <KeyState>();
        foreach (InputAction action in input.actions)
        {
            string key = action.name;
            keyStates.Add(new KeyState(key));
            action.performed += ctx => { setKeyState(key, true); };
            action.canceled  += ctx => { setKeyState(key, false); };
        }
        input.FindAction("Movement").started   += ctx => { setAxisState("Dpad", ctx.ReadValue <Vector2>()); };
        input.FindAction("Movement").performed += ctx => { setAxisState("Dpad", ctx.ReadValue <Vector2>()); };
        input.FindAction("Movement").canceled  += ctx => { setAxisState("Dpad", ctx.ReadValue <Vector2>()); };
    }
        private void Start()
        {
            // Store the original pitch of the audio source
            m_OriginalPitch = m_MovementAudio.pitch;

            // Unity 2020 New Input System
            // Get a reference to the MultiplayerEventSystem for this player
            EventSystem ev = GameObject.Find("EventSystem").GetComponent <EventSystem>();

            // Find the Action Map for the Tank actions and enable it
            InputActionMap playerActionMap = ev.GetComponent <PlayerInput>().actions.FindActionMap("Tank");

            playerActionMap.Enable();

            // Find the 'Move' action
            m_MoveAction = playerActionMap.FindAction("MoveTank");

            // Find the 'Turn' action
            m_TurnAction = playerActionMap.FindAction("TurnTank");

            // Enable and hook up the events
            m_MoveAction.Enable();
            m_TurnAction.Enable();
            m_MoveAction.performed += OnTankMove;
            m_TurnAction.performed += OnTankTurn;
        }
 public CharacterInputMapper(InputActionMap inputActionMap, bool isEnableOnStart) : base(inputActionMap, isEnableOnStart)
 {
     InteractAction = inputActionMap.FindAction("Interact");
     MoveAction     = inputActionMap.FindAction("Move");
     RunAction      = inputActionMap.FindAction("Run");
     OnPauseAction  = inputActionMap.FindAction("Pause");
 }
Exemplo n.º 8
0
    private void Awake()
    {
        anim      = GetComponent <Animator>();
        transform = GetComponent <Transform>();

        mainActionMap = playerInput.actions.FindActionMap("PlayerActions");

        moveAction   = mainActionMap.FindAction("Move");
        attackAction = mainActionMap.FindAction("Attack");

        moveAction.performed += ctx =>
        {
            Vector2 dir = ctx.ReadValue <Vector2>();
            moveDir = new Vector3(dir.x, 0, dir.y);
            anim.SetFloat("Movement", dir.magnitude);
        };

        moveAction.canceled += ctx =>
        {
            moveDir = Vector3.zero;
            anim.SetFloat("Movement", 0.0f);
        };

        attackAction.performed += ctx =>
        {
            Debug.Log("Attack by c# event");
            anim.SetTrigger("Attack");
        };
    }
Exemplo n.º 9
0
    private void Awake()
    {
        //recup la map
        InputActionMap playerMap = m_controlsInput.FindActionMap("Player");

        //recup les input/action volue
        InputAction shootAction = playerMap.FindAction("Shoot");

        //les deleguate = liste de fonction refenrencer (mettre plein de fonction et on pourra touts les recup)
        //linker une fonction en une ligne
        //ctx =nom de ka variable, contexte, contien les info besoin
        //=> c'est une fleche appeler lambda permet d'ecrire sur une seul ligne
        shootAction.performed += (ctx) => { Shoot(); };
        //autre façon mais moins pratique
        //shootAction.performed += Shoot; +  public void Shoot(InputAction.CallbackContext ctx) {}

        //move
        InputAction moveAction = playerMap.FindAction("Move");

        moveAction.performed += (ctx) => { m_MovementInput = ctx.ReadValue <Vector2>(); };
        //eviter qu'il avance alors qu'on appui pas donc on rement a 0
        moveAction.canceled += (ctx) => { m_MovementInput = Vector2.zero; };

        //dit quand les input sont activer
        playerMap.Enable();
    }
Exemplo n.º 10
0
    private void Awake()
    {
        actionMap = playerInput.actions.FindActionMap("Player");
        rotateCounterClockwise = actionMap.FindAction("RotatePlanetCounterClockwise");
        rotateClockwise        = actionMap.FindAction("RotatePlanetClockwise");
        rotateUp   = actionMap.FindAction("RotatePlanetUp");
        rotateDown = actionMap.FindAction("RotatePlanetDown");



        //Example, calling delegate without specifying any parameters
        rotateClockwise.performed += OnRotateClockwise;

        //Example, calling delegate while specifying the full parameters. This is identical to the example above
        //ctx stands for "context" and seems to be a standish way of naming the parameter
        rotateCounterClockwise.performed += ctx => OnRotateCounterClockwise(ctx);
        //Example, doing a bit of logic on the parameter and then calling the delegate
        rotateClockwise.performed += ctx => OnRotateClockwiseWithBoolean(ctx.ReadValue <float>() > 0);

        //Example, just doing some logic but not actually calling a delegate
        rotateClockwise.performed += _ => count++;

        rotateUp.performed   += ctx => OnRotateUp(ctx);
        rotateDown.performed += ctx => OnRotateDown(ctx);
    }
Exemplo n.º 11
0
    // Start is called before the first frame update
    void Awake()
    {
        _actionMap          = actionAsset.FindActionMap(controllerName);
        _inputActionGrip    = _actionMap.FindAction(actionGrip);
        _inputActionTrigger = _actionMap.FindAction(actionTrigger);

        _handAnimator = GetComponent <Animator>();
    }
Exemplo n.º 12
0
        private void Start()
        {
            UIActionMap     = testActions.FindActionMap("UI");
            quitInputAction = UIActionMap.FindAction("Quit");

            quitInputAction            = UIActionMap.FindAction("Quit");
            quitInputAction.performed += HandleQuitRequest;
        }
Exemplo n.º 13
0
    // Start is called before the first frame update
    void Awake()
    {
        //get all of our actions...
        _actionMap          = actionAsset.FindActionMap(controllerName);
        _inputActionGrip    = _actionMap.FindAction(actionNameGrip);
        _inputActionTrigger = _actionMap.FindAction(actionNameTrigger);

        //get the Animator
        _handAnimator = GetComponent <Animator>();
    }
Exemplo n.º 14
0
    private void WithMap()
    {
        //Obtenemos el mapa del asset
        //mapa = AssetEntrada.GetActionMap( "Canon" );          //Viejo?
        mapa = AssetEntrada.FindActionMap("Canon");             //nuevo en la version?

        //miMovimientoMapa = mapa.GetAction( "Movimiento" );
        //miDisparoMapa = mapa.GetAction( "Launch" );

        miMovimientoMapa = mapa.FindAction("Movimiento");
        miDisparoMapa    = mapa.FindAction("Launch");
    }
Exemplo n.º 15
0
    private void Start()
    {
        AudioManager.instance.Play("MenuMusic");

        InputActionMap Map = controller.FindActionMap("UIController");

        anyKey    = Map.FindAction("AnyKey");
        acceptKey = Map.FindAction("Accept");

        anyKey.Enable();
        acceptKey.Enable();
    }
Exemplo n.º 16
0
    void Start()
    {
        cam = Camera.main.transform;
        InputActionMap Map   = controller.FindActionMap("PlayerInput");
        InputActionMap MapUi = controller.FindActionMap("UIController");

        movementKey = Map.FindAction("Movement");
        runKey      = Map.FindAction("Run");
        interactKey = Map.FindAction("Interact");
        escKey      = MapUi.FindAction("Esc");
        tabKey      = MapUi.FindAction("Tab");
    }
Exemplo n.º 17
0
    private void Awake()
    {
        actionMap = playerInput.actions.FindActionMap("Player");
        move      = actionMap.FindAction("Move");
        jump      = actionMap.FindAction("Jump");

        move.started += OnMove;
        jump.started += OnJump;


        rb = player.GetComponent <Rigidbody>();
    }
Exemplo n.º 18
0
    public UIInputHandler(InputActionMap UIActionMap)
    {
        quitAction           = UIActionMap.FindAction("Quit");
        pauseAction          = UIActionMap.FindAction("Pause");
        takeScreenShotAction = UIActionMap.FindAction("Screenshot");
        restartAction        = UIActionMap.FindAction("Restart");

        quitAction.performed           += QuitActionRequested;
        pauseAction.performed          += PauseActionRequested;
        takeScreenShotAction.performed += TakeScreenShotActionRequested;
        restartAction.performed        += RestartActionRequested;
    }
Exemplo n.º 19
0
    private void Awake()
    {
        startPowerLevel = powerBarLevel;
        textWait        = new WaitForSeconds(0.5f);
        _currentState   = GameState.Init;
        _map            = Controls.FindActionMap("Player");

        _up      = _map.FindAction("Up");
        _down    = _map.FindAction("Down");
        _left    = _map.FindAction("Left");
        _right   = _map.FindAction("Right");
        _restart = _map.FindAction("Restart");
    }
Exemplo n.º 20
0
        private void Start()
        {
            orderGiver = new OrderGiver(hexGrid, this);
            builder    = new Builder(hexGrid);


            InputActionMap PlayerActionMap = playerInput.actions.FindActionMap("Player");

            PlayerActionMap.FindAction("SelectUnit").started        += _ => SelectEnteties();
            PlayerActionMap.FindAction("SelectUnit").canceled       += _ => ReleaseSelectionBox();
            PlayerActionMap.FindAction("GiveOrderToUnit").performed += _ => GiveOrderToUnits();
            PlayerActionMap.FindAction("SetIdleState").performed    += _ => ReturnToIdleState();
        }
Exemplo n.º 21
0
    private void Awake()
    {
        playerInput = GetComponent<PlayerInput>();

        inputActionMap = playerInput.currentActionMap;

        movementInputAction = inputActionMap.FindAction("Move");
        attackInputAction = inputActionMap.FindAction("Attack");

        movementInputAction.performed += ctx => direction = ctx.ReadValue<Vector2>();
        movementInputAction.canceled += ctx => direction = ctx.ReadValue<Vector2>();
        attackInputAction.performed += _ => OnAttack();
    }
Exemplo n.º 22
0
    public TestPlayerInputManager(InputActionMap playerMovementMap)
    {
        moveLeftAction  = playerMovementMap.FindAction("MoveLeft");
        moveRightAction = playerMovementMap.FindAction("MoveRight");
        moveUpAction    = playerMovementMap.FindAction("MoveUp");
        moveDownAction  = playerMovementMap.FindAction("MoveDown");
        jumpInputAction = playerMovementMap.FindAction("Jump");

        jumpInputAction.performed += HandleJumpInputEvent;
        moveRightAction.performed += HandleMoveRightEvent;
        moveLeftAction.performed  += HandleMoveLeftEvent;
        moveUpAction.performed    += HandleMoveUpEvent;
        moveDownAction.performed  += HandleMoveDownEvent;
    }
Exemplo n.º 23
0
    private void Awake()
    {
        InputActionMap playerMap = playerControls.FindActionMap("Player");

        InputAction shootAction = playerMap.FindAction("Shoot");

        shootAction.performed += (ctx) => { Shoot(); };

        InputAction moveAction = playerMap.FindAction("Move");

        moveAction.performed += (ctx) => { movementInput = ctx.ReadValue <Vector2>(); };
        moveAction.canceled  += (ctx) => { movementInput = Vector2.zero; };
        playerMap.Enable();
    }
Exemplo n.º 24
0
        protected virtual void CheckInputAction(ActionBasedController interactor, ActionType actionType, string defaultActionName)
        {
            InputAction defaultAction = _actionMapDefault.FindAction(defaultActionName);

            if (actionType == ActionType.Activate)
            {
                if (!interactor.activateAction.action.IsValid())
                {
                    interactor.activateAction = new InputActionProperty(defaultAction);
                }
            }
            else if (actionType == ActionType.Select)
            {
                if (!interactor.selectAction.action.IsValid())
                {
                    interactor.selectAction = new InputActionProperty(defaultAction);
                }
            }
            else if (actionType == ActionType.Haptic)
            {
                if (!interactor.hapticDeviceAction.action.IsValid())
                {
                    interactor.hapticDeviceAction = new InputActionProperty(defaultAction);
                }
            }
            else if (actionType == ActionType.UI)
            {
                if (!interactor.uiPressAction.action.IsValid())
                {
                    interactor.uiPressAction = new InputActionProperty(defaultAction);
                }
            }
        }
Exemplo n.º 25
0
    private void Awake()
    {
        _ballPlayerActionMap = _input.FindActionMap("Ball");
        _ballPlayerMovement  = _ballPlayerActionMap.FindAction("Reset");

        _ballPlayerMovement.performed += BallAddForce;
    }
Exemplo n.º 26
0
    private void SetupMenu()
    {
        InputActionMap menu = pi.FindActionMap("Menu");

        //2D Vectors
        IA_Move            = menu.FindAction("Move");
        IA_Move.performed += ctx => Move = ctx.ReadValue <Vector2>();

        //Hold Down Input
        IA_Submit            = menu.FindAction("Submit");
        IA_Submit.performed += ctx => Submit = true;
        IA_Submit.canceled  += ctx => Submit = false;

        IA_Cancel            = menu.FindAction("Cancel");
        IA_Cancel.performed += ctx => Cancel = true;
        IA_Cancel.canceled  += ctx => Cancel = false;
    }
Exemplo n.º 27
0
    void Awake()
    {
        InputActionMap actionMap = playerControls.FindActionMap("Player");

        actionMap.Enable();
        look          = actionMap.FindAction("Look");
        virtualCamera = GetComponent <CinemachineVirtualCamera>();
    }
Exemplo n.º 28
0
    private void Start()
    {
        InputActionMap Map = controller.FindActionMap("PlayerInput");

        movementKey = Map.FindAction("Movement");

        levelTutorial = 0;
    }
Exemplo n.º 29
0
    // Start is called before the first frame update


    void Start()
    {
        gravity = Physics.gravity;

        onFootMap = actionsAssests.FindActionMap("OnFoot");

        onFootMap.Enable();

        moveAction = onFootMap.FindAction("Move");

        jumpAction = onFootMap.FindAction("Jump");

        moveAction.performed += context => OnMove(context);
        moveAction.canceled  += ctx => OnMove(ctx);

        jumpAction.performed += context => OnJump(context);
        jumpAction.canceled  += ctx => OnJump(ctx);
    }
Exemplo n.º 30
0
    /// <summary>
    /// create listeners
    /// </summary>
    void Controller_Enable()
    {
        //move
        MoveAction            = ThisActionMap.FindAction(MoveRef.action.id);
        MoveAction.performed += MoveAxis;
        MoveAction.canceled  += MoveAxis;
        //crouch
        CrouchAction            = ThisActionMap.FindAction(CrouchRef.action.id);
        CrouchAction.started   += OnCrouch;
        CrouchAction.performed += OnCrouch;
        CrouchAction.canceled  += OnCrouch;
        //jump
        JumpAction            = ThisActionMap.FindAction(JumpRef.action.id);
        JumpAction.started   += OnJump;
        JumpAction.performed += OnJump;
        JumpAction.canceled  += OnJump;

        DelegatesEnabled = true;
    }