Problems with collisions and scaled movement with AddMovementInput

Hi all!

I think i have a problem with the acceleration of the AddMovementInput function.

In my spaceship project i have a spaceship with 4 instances of a component i made to do raycasting, and i use them to check if the spaceship can move forward, backward, left and right (i have 4 walls in the world delimiting the area where the spaceship can move).

If i move the spaceship “GetOwner()->SetActorLocation(newLocation)”, for example, it moves forward and, when the raycast touches the forward wall, it stops moving instantly.
But, if use “AddMovementInput(FVector::ForwardVector, Movement.X * MovementSpeed * DeltaTime)” instead, if the spaceship reaches the wall at full speed, sometimes it gets into the wall.

This first screenshot was taken moving the spaceship with SetActorLocation


This one, with AddMovementInput


My GoForwardCode (uses SetActorLocation):



void UPawnMovementModule::GoForward(float deltaTime, bool reverse)
{
    FVector newLocation = GetOwner()->GetActorLocation();    

    if (!reverse)
    {
        if (CanMoveTo.Forward)
        {
            newLocation += (GetOwner()->GetActorForwardVector() * MovementSpeed * deltaTime);
        }
    }
    else
    {
        if (CanMoveTo.Backward)
        {
            newLocation += (-GetOwner()->GetActorForwardVector() * MovementSpeed * deltaTime);
        }
    }

    GetOwner()->SetActorLocation(newLocation);
}


The Movement structure used in with AddMovementInput stores each axis value (from the input events).

Also, if i use a speed of 60 while i use AddMovementInput, the spaceship goes fast, but i have to use a value of 600 with SetActorLocation to achieve the same speed :S.

See ya!

Bump!

Any idea? Anybody? :frowning:

See ya!