• Weird Spectate / SetObserverMode()
    14 replies, posted
Okay - I'm making a gamemode and this issue is puzzling. Here is the code I'm having an issue with: [CODE] function GM:PlayerDeath(ply, inflictor, attacker) ply:StripWeapons() ply:SetMoveType(MOVETYPE_NOCLIP) ply:SetCollisionGroup(10) ply:Spectate(6) end [/CODE] The issue I'm having is that when the player dies, it puts them into this bizzare movement mode where they are not noclipped, and only able to navigate using their backwards move button (s). They can fly into the air, but still have gravity causing them to fall back to the ground. I have also tried SetObserverMode(6) Any help with this? Also, if this is in the wrong area - my sincere apologies. Direct me to the correct area and I'll delete this thread and post it there. Thanks a ton for any help, ~Nick
In case anybody was wondering, I've also tried this with GM:DoPlayerDeath(ply,inflictor,attacker)
Hm. Nobody? I really need help here.
Not sure if it works, but you could try setting their movetype to MOVETYPE_NONE apon death.
What does that do? I'll give it a shot -EDIT- No luck with movetype_none
What are you even doing? Just do ply:Spectate( 6 ).
I've tried that - and it still doesn't work. You'll see in the code that ply:Spectate(6) is actually a line... But whenever I try free roam of any kind it just bugs out and you can't be noclipped or move normally.
Remove everything but ply:Spectate( 6 ). Your [code] ply:StripWeapons() ply:SetMoveType(MOVETYPE_NOCLIP) ply:SetCollisionGroup(10) [/code] nonsense is what makes it go wrong.
Does not work. Just as glitchy, just in a different way.
What is it you're trying to do exactly?
[QUOTE=rainbowpanda;40372330]Does not work. Just as glitchy, just in a different way.[/QUOTE] I feel like you must be doing something else causing it to fuck up then.. [lua]function _R.Player:SpawnAsObserver() self:StripWeapons() self:KillSilent() self:Spectate( OBS_MODE_ROAMING ) self:Freeze( false ) end function _R.Player:SpawnAsSpectator() self:SpawnAsObserver() self:SetTeam( TEAM_SPECTATOR ) end[/lua] I use this for my spectating stuff, and it works fine.
[QUOTE]What is it you're trying to do exactly?[/QUOTE] I'm trying to, on PlayerDeath, set them into a spectator mode where they can free-roam. Do they have to be alive for this? I've tried many different ways: Setting observer/spectate type to roaming Spawning player + making him invisible some other stuff that is embarrassing and would obviously not work I can't figure out why this isn't working correctly - tried BlackAwps's solution with little luck.
In my experience, with spectate it just changes the camera to that of another entity, so it's best to hide the player somewhere and restrict movement. You can try creating an invisible entity, make the player spectate that and use entity driving to move around.
That doesn't make sense to me at all XD Can you elaborate?
I can't really say much else without booting up gmod and trying it myself. Maybe BlackAwps can provide more info for you and I both.
Sorry, you need to Log In to post a reply to this thread.