Issue with FMath::InterpTo

Hello

I’m actually designing my level and found now a little issue.
My plan was to make the player solve several puzzles and in the end should the gargoyle with the stand appear out of the floor, for the player to grab it and to escape. Unfortunately the function FMath::FInterpTo seems to fade out forever and when I grab it, it seems to blur and flash around, combined with the rotation it gets really weird. I used the code below to design the MoveUp function, which is called within the TickComponent.

void UMoveGargoyleUp::MoveUp(float DeltaTime)
{
	CurrentHeight = FMath::FInterpTo(CurrentHeight, TargetHeight, DeltaTime, MoveUpSpeed);
	FVector NewPosition = GetOwner() ->GetActorLocation();
	NewPosition.Z = CurrentHeight;
	GetOwner() ->SetActorLocation(NewPosition);
}

Does someone know a solution, where I can stop this behaviour?

Ok, seems like I solved the issue with the following code. Though it’s just straight movement and not getting slower in the end. And I needed to adjust the gargoyles damping, because it fell of the stand.

void UMoveGargoyleUp::MoveUp(float DeltaTime)
{
	if (!GargoyleMoved && CurrentHeight <= TargetHeight)
	{
		CurrentHeight += MoveUpSpeed * DeltaTime;
		FVector NewPosition = GetOwner() ->GetActorLocation();
		NewPosition.Z = CurrentHeight;
		GetOwner() ->SetActorLocation(NewPosition);		
	}
	else
	{
		GargoyleMoved = true;
	}
}

Maybe someone finds a better solution. For now I can work with it. :slight_smile:

I’m not quite sure what the issue is from your description. However there is VInterpTo for vectors which might provide better movement

FVector Location = GetOwner()->GetActorLocation();
Location = FMath::VInterpTo(Location, TargetVector, DeltaTime, MoveUpSpeed);
GetOwner()->SetActorLocation(Location);

Thank you. I tried this too and it didn’t work either. The problem is, with these functions the movement of my object will never really be finished and when I try to pick it up to solve my puzzles it continues to move by this code. So I implemented a linear movement, which will be stopped at my targeted position and I needed to make sure, that when the player moves the object, my code does’t want to move it back again. Though I’m not quite sure if the second problem I solved with the bool GargoyleMoved would work with the VInterpTo function. Maybe like this I can get my desired movement. I will try this later.

Oh right, well due to the nature of things it’s very unlikely that it’s going to reach the end point (as you’ve seen).

This is why these functions exist

I tried both and they seem to work.
Thank you.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.