If you don’t mind that your pawn/character kind of “jumps” to the new position you can use the AddLocalOffset/AddWorldOffset of your pawn/character. You can bind that to a buttonpress so you can kind of fall 50 units if you press one button and fall 100 units if you press an other button. If you don’t want your pawn/character to jump, you could use some interpolation, so it travels smooth to the desired location.
I want to move a simple Pawn object to fall from the sky upon being spawned but instead of simply crushing to floor it has to move on the Y Axis. This wouldn’t be such a big problem if I made it move continuously as one would do with a Character object but I want it to use a discrete movement.
What I mean is that it should move the same way the Tetris pieces do when they fall from the top of the grid: after X seconds, they drop down by Y centimeters and so on until they touch the floor.
I need the “jump” on every tick so this is perfect. Thanks a lot
you could do something like this:
APawn* pawn; FVector newLocation; FHitResult hit; pawn->SetActorLocation(newLocation, true, &hit, ETeleportType::TeleportPhysics);
this will Move the Actor to the new Location in one frame, without affecting its physics velocity. It will also sweep, which means it will detect any object between it and its target position and stop if it hits something (the ground for example).
Check out the documentation page for more details:
You might also want to check out this page, which shows exactly how you can move a physics object and what teleporting and sweeping actually does in a visual way.
The only thing left to do is to actually calculate the new position. You might want to store a custom calculated veloctiy on your pawn, so you can calculate your new position each frame. The rest is simple algebra.
This solution is a bit more heavy weight, than the comment above, but it is also more powerfull.