How should I be using the Actor.InputComponent?
See original GitHub issueI 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:
- Created 3 years ago
- Comments:18 (18 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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
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.