Hello! Fairly new to UE4 here, more like an on off thing, mostly work in Unity. So, here I have a function that takes input which moves my character forward.
void Awalking::walk_forward(float input)
{
if (Controller && input)
{
UE_LOG(LogTemp, Warning, TEXT("Moving Forward!"));
//caps_comp->AddImpulse(FVector(GetActorForwardVector()) * 300.0f);
AddMovementInput(GetActorForwardVector(), input);
}
}
It works just as well as it should for the intended purpose. However! I have this other block of code that makes my character jump, which only works when I have Physics/Collision active.
void Awalking::jumping(float jumpstr)
{
if (Controller && jumpstr)
{
if (caps_comp && jump == false)
{
UE_LOG(LogTemp, Warning, TEXT("Jumping"));
//mesh_comp->AddImpulse(FVector(GetActorUpVector()*mesh_comp->GetMass()) * 300.0f);
caps_comp->AddImpulse(FVector(GetActorUpVector() * caps_comp->GetMass()) * 300.0f);
jump = true;
}
}
}
Now when I have Physics or Collision active, AddMovementInput does not work, I’ve tried adding movement input to the Up vector, and it doesn’t work. Here’s a list of things I’ve tried:
void Awalking::jumping(float jumpstr)
{
if (Controller && jumpstr)
{
if (mesh_comp && jump == false)
{
UE_LOG(LogTemp, Warning, TEXT("Wuddup"));
//mesh_comp->AddImpulse(FVector(GetActorUpVector()*mesh_comp->GetMass()) * 300.0f);
//caps_comp->AddImpulse(FVector(GetActorUpVector() * caps_comp->GetMass()) * 300.0f);
//AddMovementInput(FVector(GetActorUpVector() * caps_comp->GetMass()) * 300.0f, jumpstr);
//mesh_comp2->AddImpulse(FVector(GetActorUpVector()*mesh_comp->GetMass()) * 300.0f
//AddMovementInput(GetActorUpVector() * jumpstr * 3000.0f, jumpstr);
jump = true;
}
}
}
Sorry about indentation, part of the code gets cut off into the next line when posting this question, and it bugs me. Also Yes I want it to jump once, and most of this is experimentation.
Is there something I am missing? Does AddMovementInput not function with Physics/Collision? Adding forward impulse only knocks the character over. Thank you for your time!