I’m working on a unstuck command, cant find a simple yet effective way to get the closest location to a vector, that can house a certain sized object, eg a player.
You can use TraceHull. Player HullSize is -16, -16, 0 to 16, 16, 72 or so. Use OBBMins and OBBMaxs to get the exact size. Player:GetPos( ) is in the middle of the player, at the feet.
If you know the reason why a player gets stuck ( such as exiting a vehicle, or a certain area on a map ) then it is easier and more cost effective to fix the issue ( by blocking off a part of a map with an invisible wall, or using default Garry’s Mod exit vehicle logic ) than creating an “unstick” algorithm…
Some of the problems you may run into: Some maps have player size areas under the map, just outside the walls of a map, etc… If you move through a wall in your algorithm, then you may end up with a player out of the map. Another one is being too unrestrictive… Don’t just test every area unit by unit… 4/3 units = 1 inch, 16 = 1 foot. Player is 2 feet by 2 feet by 4.5 feet… If you move through then move in 8, 16 or 32 unit intervals. Make sure you don’t put the player in the ceiling… A few test traces may help ( non hull ) determine areas to test.