Character movement via SetActorLocation

4e6yp
Mon, 26 Jun 2017 16:42:14 +0000
Character & Animation

Hello. I’ve been trying to create replicated top-down character (like air hockey striker), controlled by mouse. It must follow mouse movement precisely to be comfortable for player. I couldn’t find a way to use AddMovementInput, because it wasn’t feeling responsive. I’ve tried to tweak all of the CharacterMovement variables (acceleration/braking friction/ground friction and others), but unsuccessfully.

So I’ve implemented movement with SetActorLocation function after getting Forward and Right InputAxis. I call it on client and then on server (pic. 1). It feels just right to control, but I’ve ran into some problems with that.

First of all – I can’t move along the obstacle on my way. I use SetActorLocation with sweep, so when I hit any obstacle – character just stops. I’ve found a solution (pic. 2) to move along the wall with normal vector, where either X or Y == 0. For example, if hit normal vector == (0, 1, 0), then I move along X axis. Z axis doesn’t matter; character is constrained to XY-Plane. But if normal vector == (0.4, 0.6, 0), then I can’t figure out how to move along the obstacle surface. So the question is - how to move along obstacle with SetActorLocation type of movement. I’ve tried to calculate surface equation, it kind of worked, but since it’s being called each tick – it was very laggy.

Second problem is how to handle ping situation with that kind of movement. If character hits some object on server while on client it didn’t hit anything – character on client teleports to hit point for one tick and then comes back to previous location. I tried to set flag “Ignore Client Movement Error check”, but it doesn’t work as I thought it would. Is there any other way to ignore Server-Client location correction?

Thank you for any help!

1 post - 1 participant