Input Component Issue v4.12.5

I’m not sure what versions the rest of you guys are using, or in what version is was changed, but Input Component seems to have been replaced by Movement Component. UInputComponent is still a valid statement but it wasn’t what was spawning on the Default Pawn at runtime so the Log to check for it wasn’t working.

With a little code editing I got it working fine, just has to use UMovementComponent instead. Just a heads up for anyone else who may have run into this issue.

EDIT:

Also just found out that BindAction doesn’t seem to be accessible through UMovementComponent so I had to add the private variable for the InputComponent back into the header file to regain the access. Not sure if there’s another way around it but that was my solution.

Those are two completely different things. What was your original code?

Originally my code was the same as the videos since I was having issues. It wouldn’t report that the Input Component was found so I tinkered around for a little bit and tried it with Movement Component, it would report for MC but not IC.

It was rather confusing why it wasn’t working but then I started to get crashes upon Play or Simulate so I rebuilt the whole project, remade the code in question and the IC reported just fine… let’s chalk that up to weird things happen when you’re studying game design at 3AM.

Not sure why it was giving me problems but you’re right, they are two separate things and people should probably ignore the first post. Maybe I accidentally caused a conflict of some kind doing that.

Hello Danm I have a question about BindAction();

  1. as it seems BindAction has the same syntax as FindComponentByClass both of them has triangular braces < > and then round braces ( )
    but into the BindActoin we did not set the parameter which is required triangular braces. and why?
    and how can function works the missing parameters?
  2. I can not understand red underline code, what it’s means? and why this hard syntax equal &UGrabber::Grab
  1. Template argument type deduction. The compiler is able to deduce the type so it’s not required, those same rules for template type deduction apply to auto
  2. That’s a function pointer type Unreal has created. Look into function pointers for an idea for what it’s doing.
  1. if Template argument is type deduction and apply to auto, why this function
    InputComponentt = GetOwner()->FindComponentByClass <UInputComponent(); requires triangular braces argument. without UInputComponent parameter the function is not works?

  2. TBaseDelegate<TTypeWrapperr<void ::TUObjectMethodDelegate<UserClass::FMethodPtr Func
    I can not understand what means this line. A little I recognize UserClass and FMethodPtr Func which would be connected with Grabber class and Grab function, but without course lesson I could not arrange BindAction() . I know what it is doing but I can not understand it’s syntax. please if you can tell me more about this line.

  3. &UGrabberr::Grabb it’s not like C++ syntax. I cannot write function which would have been an argument class member function. here is my challenge:

     **class A {
     private:
     	int x, y;
     public:
     	A() { cout << "A Constructor..." << endl; }
     	//A(int a,int b): x(a),y(b){}
     	void TEXT() { cout << "TEXT Function..." << endl; }
     	void SetData(int a, int b) { x = a; y = b; }
     	void Print() { cout << "X = " << x << " Y = " << y << endl; }
     	void AllFunction(void *SetData(int, int), void *TEXT(),void *Print(),int a, int b) { // Syntax is right
     		SetData(a, b);                  // but cannot call this function
     		TEXT();
     		Print();
     	}
     	
     };
    

    bool Myltiple_3(int x) { return x % 3 == 0; }

    void Printt(int x) { cout << x << endl; }

     void MixFunction(bool Myltiple_3(int), void Printt(int), int* ptr, int size) { // It's works fine
     	for (int i = 0; i < size; i++) {                                          // but it's argument is not 
     	if (Myltiple_3(ptr[i])) Printt(ptr[i]);                              // class memeber functions
     }
     }
    

    void MixFunction_2(&A::SetData, &A::TEXT) {} // Cannot write it’s syntax.

    int main() {

     int array[5] = { 13,15,18,22,27 };
     MixFunction(&Myltiple_3, &Printt, array, 5);
    
     A a;
     a.AllFunction(&A::SetData) // Cannot call
     system("pause");
     return 0;
    

    }

  1. Because there’s nothing to deduce the type from. With BindAction we supply the argument which uses the template paramater with this and the compiler can deduce the template argument type with it. I suggest you watch this 2 part talk on normal template programming. Which also goes over template type deduction and how that works.

For a brief overview

template<typename T>
T Abs(T t)
{
    return t > 0 ? t : -t;
}
int main()
{
    Abs(-2); //T deduced to be int
    Abs(3.8); //T deduced to be double
    Abs(-3.f); //T deduced to be float
    Abs<int>(2.8); //Template argument supplied, T is int.
}
  1. It’s not important to know what’s going on in that, it’s just some type Unreal made for a function pointer.
  2. Yes it is C++ syntax. With non-member functions:
#include <iostream>
#include <string>

using StringFuncPtr = std::string(*)();

void Print(StringFuncPtr func) { std::cout << func() << std::endl; }
std::string Nothing() { return "Nothing"; }
std::string Something() { return "Something"; }

int main()
{
	Print(&Nothing);
	Print(&Something);
}
  1. yes as you say syntax is right but argument function will not be class member function
    and on this ground why this &UGrabberr::Grabb work?
    I tried many times but cannot write similar order

Because that’s a non-static member function, it’s useless to call the function without an instance of that object to call it on, which is why in the Bind function we pass this.

#include <iostream>
#include <string>

struct Foo
{
	std::string Func() { return "Foo"; }
};

using StringMemFuncPtr = std::string(Foo::*)();
void Print(Foo f, StringMemFuncPtr func) { std::cout << (f.*func)() << std::endl; }

int main()
{
	Foo f;
	Print(f, &Foo::Func);
}

thank you DanM :slight_smile: your answer is always helpful

Privacy & Terms