question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How should I be using the Actor.InputComponent?

See original GitHub issue

I have just been playing with the samples and I’m getting null ref exception when I call InputComponent.BindAction()

public static class ObjectOrientedDesign
{
    private static Player _player;
    public static void OnBeginPlay()
    {
        Debug.AddOnScreenMessage(-1, 3.0f, Color.LightGreen, MethodBase.GetCurrentMethod().DeclaringType + " system started!");

        Engine.AddActionMapping("TestInput", Keys.W);
        _player = new Player(nameof(Player));
    }
}

public class Player : Actor
{
    public Player(string name = null) : base(name) => InputComponent.BindAction("TestInput", InputEvent.Repeat, InputTest);
    public void InputTest() => Debug.AddOnScreenMessage(-1, 0.1f, Color.Aqua, $"Input {World.RealTime}");
}

Is this not the correct usage?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18 (18 by maintainers)

github_iconTop GitHub Comments

1reaction
ScottKanecommented, Aug 14, 2020

Yeah no doubt, you could also just start a subreddit until discussions go live. On a side note I had a thought for future improvements, as you have a core runtime, you could in theory use Blazor as a way of creating UI from code which would be insanely cool

1reaction
ScottKanecommented, Aug 14, 2020

Sure, I have been working with Unity for a while so a bit out of the loop on how things are done in Unreal so excuse the rusty knowledge with which classes I should be using for some things. If things go to plan though I would be much happier in Unreal with UnrealCLR than Unity, they are stuck on full framework and haven’t even gotten up to netstandard2.1 support yet, C# 8 isn’t fully implemented (no default interface implementations) as well as no Nuget integration.

I know a lot of actual developers (not script kiddies) using Unity will likely move to Unreal when this plugin gets fully off the ground. Have to say I’m really impressed with the coverage you have achieved in such a short space of time.

Read more comments on GitHub >

github_iconTop Results From Across the Web

InputComponent and Actors - C++
So recently I have been working on some code and I did the same type of setup in two places and I get...
Read more >
Binding Input in C++ with Unreal Engine 4 - Unrealistic
Every Actor possesses an Input Component (though it is not always initialized), and the way to bind to inputs once you have the...
Read more >
Interaction By Actor Component - UE4 Advanced Blueprints ...
Short series of videos about the interaction between actors done in Unreal Engine. The methods mentioned are : 1. Cast To 2.
Read more >
Game Actors Or Input Components?
I would advise against having an input component that reads straight off the input hardware. It makes it unnecessaily difficult to switch the ......
Read more >
Handling Input on arbitrary Actor classes in C++
This example shows you how to bind functions to input events on any Actor class.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found