The :MoveTo() method of models is great for teleporting a model while avoiding anything that may be obstructing the given position. The problem with MoveTo() is that it only moves the model straight up and not to the nearest open space around the position as seen here. This looks great if the position is in the ground, but not so much if the position is in a wall.
This is very useful for combat games if we need to correct a character’s position. Normally, players being up against walls or having their limbs clipping into walls is not an issue- but in combat games if you ragdoll them while their limbs are inside walls they get glitched (see below).
The issue with using MoveTo() to position the character before ragdolling them is that moving them straight up would look unrealistic in a combat game. It would be much more desirable if we could move them to the nearest open space.
I have made a prototype module that does just this (see below). However, its very unperformant as it requires a large amount of block casting or spatial queries as seen here. It would be against our interest to have the client do this since there would be latency and the server position would remain the same. Even if we did- the approach is still too costly even on the client.
I was wondering if anyone knew of any clever approach to this issue. The goal is really just to move the character to the nearest open space around a position if that position is obstructed. Thanks!
So far, the approach I’ve used works, its just horribly unperformant.