Exemple #1
0
        public static void OnBeginPlay()
        {
            Assert.IsFalse(variable.IsBool);
            Assert.IsFalse(variable.IsFloat);
            Assert.IsFalse(variable.IsString);
            Assert.IsTrue(variable.IsInt);
            Assert.IsTrue(variable.GetInt() == variableValue);

            variable.SetOnChangedCallback(VariableEvent);

            ConsoleManager.RegisterCommand(consoleCommand, "Executes a test command", ConsoleCommand);

            Assert.IsTrue(ConsoleManager.IsRegisteredVariable(consoleCommand));

            Engine.AddActionMapping(pauseResumeAction, pauseResumeKey);
            Engine.AddAxisMapping(mouseXAction, mouseXKey);
            Engine.AddAxisMapping(mouseYAction, mouseYKey);

            InputComponent inputComponent = playerController.InputComponent;

            Assert.IsFalse(inputComponent.HasBindings);

            inputComponent.BindAction(pauseResumeAction, InputEvent.Pressed, PauseResume, true);
            inputComponent.BindAxis(mouseXAction, MouseXMessage);
            inputComponent.BindAxis(mouseYAction, MouseYMessage);

            Assert.IsTrue(inputComponent.HasBindings);
        }
Exemple #2
0
        protected override void BeginPlay()
        {
            base.BeginPlay();
            Log.Debug("[BeginPlay] " + typeof(InputComponent).Name);

            m_Input = Actor.GetComponent <InputComponent>();
            Log.Debug("[A] " + m_Input.NativeHandler.ToInt64());

            m_Input.BindAxis("Horizantal", Axis_Horizantal);
            m_Input.BindAxis("Vertical", Axis_Vertical);
        }
Exemple #3
0
        protected override void BindInput(InputComponent playerInputComponent)
        {
            base.BindInput(playerInputComponent);

            // Bind the jump action to Character.Jump(), which already has the appropriate delegate signature.
            playerInputComponent.BindAction(InputAction.Jump, InputEventType.Pressed, Jump);
            playerInputComponent.BindAction(InputAction.Jump, InputEventType.Released, StopJumping);

            playerInputComponent.BindAxis(InputAxis.MoveForward, MoveForward);
            playerInputComponent.BindAxis(InputAxis.MoveRight, MoveRight);

            // We have 2 versions of the rotation bindings to handle different kinds of devices differently
            // "turn" handles devices that provide an absolute delta, such as a mouse.
            // "turnrate" is for devices that we choose to treat as a rate of change, such as an analog joystick
            playerInputComponent.BindAxis(InputAxis.Turn, AddControllerYawInput);
            playerInputComponent.BindAxis(InputAxis.TurnRate, (float axisValue) => AddControllerYawInput(axisValue * BaseTurnRate * World.GetWorldDeltaSeconds()));
            playerInputComponent.BindAxis(InputAxis.LookUp, AddControllerPitchInput);
            playerInputComponent.BindAxis(InputAxis.LookUpRate, (float axisValue) => AddControllerPitchInput(axisValue * BaseLookUpRate * World.GetWorldDeltaSeconds()));

            // handle touch devices
            playerInputComponent.BindTouch(InputEventType.Pressed, (fingerIndex, location) => Jump());
            playerInputComponent.BindTouch(InputEventType.Released, (fingerIndex, location) => StopJumping());

            // VR headset functionality
            playerInputComponent.BindAction(InputAction.ResetVR, InputEventType.Pressed, OnResetVR);
        }
Exemple #4
0
        protected override void BeginPlayingState()
        {
            InputComponent.BindAction("Fire", EInputEvent.IE_Pressed, OnFirePressed);
            InputComponent.BindAction("Fire", EInputEvent.IE_Released, OnFireReleased);

            InputComponent.BindAction("Jump", EInputEvent.IE_Pressed, () => GetCharacter()?.Jump());
            InputComponent.BindAction("Jump", EInputEvent.IE_Released, () => GetCharacter()?.StopJumping());

            InputComponent.BindAxis("Turn", v => GetCharacter()?.AddControllerYawInput(v));
            InputComponent.BindAxis("LookUp", v => GetCharacter()?.AddControllerPitchInput(v));
            InputComponent.BindAxis("MoveForward", OnMoveForward);
            InputComponent.BindAxis("MoveRight", MoveRight);
        }
        public void OnBeginPlay()
        {
            Assert.IsFalse(variable.IsBool);
            Assert.IsFalse(variable.IsFloat);
            Assert.IsFalse(variable.IsString);
            Assert.IsTrue(variable.IsInt);
            Assert.IsTrue(variable.GetInt() == variableValue);

            variable.SetOnChangedCallback(VariableEvent);

            ConsoleManager.RegisterCommand(consoleCommand, "Executes a test command", ConsoleCommand);

            Assert.IsTrue(ConsoleManager.IsRegisteredVariable(consoleCommand));

            Engine.AddActionMapping(pauseResumeAction, pauseResumeKey);
            Engine.AddAxisMapping(mouseXAction, mouseXKey);
            Engine.AddAxisMapping(mouseYAction, mouseYKey);

            playerInput.AddActionMapping(playerCommandAction, playerCommandKey);

            InputComponent inputComponent = playerController.InputComponent;

            Assert.IsFalse(inputComponent.HasBindings);

            inputComponent.BindAction(pauseResumeAction, InputEvent.Pressed, PauseResume, true);
            inputComponent.BindAction(playerCommandAction, InputEvent.Pressed, PlayerCommand, true);
            inputComponent.BindAxis(mouseXAction, MouseXMessage);
            inputComponent.BindAxis(mouseYAction, MouseYMessage);

            Assert.IsTrue(inputComponent.HasBindings);
            Assert.IsTrue(inputComponent.ActionBindingsNumber == 2);

            const string removableAction = "TestRemovable";
            const string removableKey    = Keys.R;

            playerInput.AddActionMapping(removableAction, removableKey, ctrl: true, alt: true);
            playerInput.RemoveActionMapping(removableAction, removableKey);
        }
        public void RemoveAxisBinding_ShouldRemoveRegisteredAxisBinding()
        {
            // Arrange
            var          inputComponent = new InputComponent();
            const string axisName       = "AxisName";

            inputComponent.BindAxis(axisName, value => { });

            // Act
            inputComponent.RemoveAxisBinding(axisName);

            // Assert
            Assert.That(inputComponent.AxisBindings, Does.Not.ContainKey(axisName));
        }
        public void BindAxis_ShouldRegisterAxisBinding()
        {
            // Arrange
            var inputComponent = new InputComponent();

            const string    axisName = "AxisName";
            Action <double> action   = value => { };

            // Act
            inputComponent.BindAxis(axisName, action);

            // Assert
            Assert.That(inputComponent.AxisBindings.ContainsKey(axisName), Is.True);
            Assert.That(inputComponent.AxisBindings[axisName], Is.EqualTo(action));
        }