• Check if a player is stuck
    4 replies, posted
How do I check if a player is stuck in a wall, a prop, or another player? Right now I've got two checks: 1st, are they :OnGround()? If you're stuck, you're not on the ground. The player's animation gives evidence of this. 2nd, if I launch them in a direction, do they move? If so, they aren't stuck. Repeat for x, y, and z. Is there another method of doing this that would be simpler?
[QUOTE=Handsome Matt;43476888]Do a trace from them in any direction with the player as a filter. Maybe..[/QUOTE] Would a trace HULL starting and ending at the player's position work? [editline] example: [/editline] [lua] local pos = ply:GetPos() local tracedata = {} tracedata.start = pos tracedata.endpos = pos tracedata.filter = ply tracedata.mins = ply:OBBMins() tracedata.maxs = ply:OBBMaxs() local trace = util.TraceHull( tracedata ) if trace.Entity and (trace.Entity:IsWorld() or trace.Entity:IsValid()) then --They're stuck. end [/lua]
You might wanna look at [url=http://wiki.garrysmod.com/page/PhysObj/IsPenetrating]PhysObj.IsPenetrating[/url] [editline]9th January 2014[/editline] I'm not too sure if it works properly on ragdolls/players, I haven't checked
Sorry, you need to Log In to post a reply to this thread.