x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Collision/Physics not working with with AddMovementInput

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!

Product Version: UE 4.16
Tags:
more ▼

asked Nov 09 '17 at 11:03 AM in C++ Programming

avatar image

Donut5
13 2 6

avatar image Donut5 Nov 13 '17 at 04:20 AM

Bump, does anyone have an answer?

avatar image Donut5 Nov 18 '17 at 02:39 PM

Just one more bump.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question