Hi!
I am very new using UE4 (my first week learning). I am very confused between what goes to C++ and to the Blueprint editor and how are related between each two.
So, I have started a c++ top down project. I have setup a character “behaviour” from idle → walking → to running through blueprint event and animation graph.
So I have basically 2 variables, which are speed and isAttacking.
The speed works more o less good, since is the tutorial I find everywhere, but I did instead of a blended animation, just as separated animations to see if I managed although for what I read is not the best way (learning purposes!). Sometimes the animation gets stuck in the run, but if i debug the graph works good the graph, so I hope is only a visual thing of the editor, but thing for another moment!
Also in the c++ part is done by default when you create the project.
So then I have mapped in the settings/input, that when you press A key, you “should attack”. The idea is to move from idle to attacking state when “isAttacking is true”, and go back when the attacking animation is almost finished.
I have created the following code in the c++ part:
void ArpgPlayerController::SetupInputComponent()
{
// set up gameplay key bindings
Super::SetupInputComponent();
....
InputComponent->BindAction("ResetVR", IE_Pressed, this, &ArpgPlayerController::OnResetVR);
// THIS IS MY CODE!
InputComponent->BindAction("Attack", IE_Pressed, this, &ArpgPlayerController::OnAttack);
}
void ArpgPlayerController::OnAttack()
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "HELLO!");
}
So I have setup the OnAttack function, that is bound to the “Attack” input key “A”.
But in here I am totally stuck. If I press A, certainly appears hello on the screen, but I don’t know if in here I should set the variable “isAttacking” to true (and if so, i don’t know how to access to it), and when the key A is released then set to false. Or I am doing to much and it’s not necessary to do this like that because maybe I can do from the editor directly…
Also I don’t have very clear where is the line between to add stuff in c++ and into blueprints (or if I can combine them, like trivial easy things in blueprints and more complex things in c++), and neither in how they are connected (c++ with the blueprint editor). I think this is the part that I’m the most confused right now.
I hope I could post clear, since I am also learning the terminology and probably I name things wrong
Thanks a lot for your time.