Hi so I’ve set up a box overlap component on player 1 and once it overlaps with player 2, player 2 now can’t move and it’s location is set to that boxes location so is sort of attached to the player (sorry if this is hard to understand but it’s for a pushing effect that will have animations later). This all works perfectly fine if player 2 is at max walk speed when it enters the box but if player 2 is in the state of accelerating when entering the box, it causes a jerky movement where the player snaps forward and back in two frames which I can’t understand why. Please can someone help me out I’ve been stuck all day, any help is much appreciated.
Normal when collided at max walk speed:
Jerky movement that occurs for one frame then returns back to the frame above when in a state of accelerating:
My code in c++ detects the overlap, sets the other players location to be the second picture then whenever the player moves, set that location again relative to the player it is now ‘attached’ to for now and I’m pretty sure the error is in the latter so here is the code for that that occurs whenever the player moves:
float CurrentPlayerX = Player->GetActorLocation().X; float NewOtherPlayerLocationX = CurrentPlayerX + (SetDifferenceToAdd * PushXDirection); FVector CurrentOtherPlayerLoc = OtherPlayer->GetActorLocation(); FVector NewOtherPlayerLoc = FVector(NewOtherPlayerLocationX, CurrentOtherPlayerLoc.Y, CurrentOtherPlayerLoc.Z); OtherPlayer->SetActorLocation(NewOtherPlayerLoc, true);