Did some searching, couldn't find anything
So how can I get an npc to follow a player correctly, my first attempt was having a timer
using SetLastPosition and SetSchedule but that was pretty buggy.
edit: Instead of making a new thread i'll just edit this
I need a way to make players invisible, but still rendered.
I'm attaching Clientside ragdolls to players, SetColor doesn't seem to work correctly
PrePlayerDraw hook stops the models from being seen, and I can still see myself with SetNoDraw
[img_thumb] http://www.facepunch.com/fp/ratings/funny2.png [/img_thumb]
Have you tried NPC.SetNavGoal for your NPC problem? It looks like you solved your second one.
Thanks, I'll try that.
And no I haven't solved my second problem, I'm setting the player to a mostly invisible material, which I don't like.
edit:
[lua]
--the npc is set from console
someNpc:NavSetGoalTarget( player.GetByID(1), Vector(0,0,0) )
someNpc:SetSchedule( SCHED_FORCED_GO_RUN ) -- With and without this
[/lua]
Doesn't seem to do anything :v: I'm probably leaving something out
From the E2 code:
[CODE]e2function void entity:npcGoWalk(vector rv2)
if !validNPC(this) || !isOwner(self,this) then return end
this:SetLastPosition( Vector(rv2[1], rv2[2], rv2[3]) )
this:SetSchedule( SCHED_FORCED_GO )
end
e2function void entity:npcGoRun(vector rv2)
if !validNPC(this) || !isOwner(self,this) then return end
this:SetLastPosition( Vector(rv2[1], rv2[2], rv2[3]) )
this:SetSchedule( SCHED_FORCED_GO_RUN )
end
[/CODE]
Looks like you were doing it right the first time. Make sure you are not spamming this function. I noticed on flatgrass that NPC pathing was messed up, so you can't just set the position on the other side of the map. A work around in my e2 was to set the position about 200 units in the direction i wanted them to go, then when he got there repeat until the npc is at his destination. It may work in other maps. You can then use [URL]http://wiki.garrysmod.com/?title=NPC.IsCurrentSchedule[/URL] to figure out if he is done moving, unless you have another way like a schedule hook.
As for the invisible player problem, I've seen in a few swep bases setting the alpha to one instead of zero, so that the drawing hooks are still called. I've never tried doing this on a player, so I don't know if this solves the problem.
Hope this helps!
Thanks for the help. But with SetColor the alpha didn't change anything. if I set a player's color to
255,0,0,0 he was still visible (but not red). Even if I set the alpha to 1.
If I set the color to 255,0,0,255 he was red.
\ulib\lua\ULib\server\player.lua
[CODE]
function ULib.invisible( ply, bool, visibility )
if not ply:IsValid() then return end -- This is called on a timer so we need to verify they're still connected
if bool then
visibility = visibility or 0
ply:SetRenderMode( RENDERMODE_TRANSALPHA )
ply:Fire( "alpha", visibility, 0 )
ply:GetTable().invis = { vis=visibility, wep=ply:GetActiveWeapon() }
if ply:GetActiveWeapon():IsValid() then
ply:GetActiveWeapon():SetRenderMode( RENDERMODE_TRANSALPHA )
ply:GetActiveWeapon():Fire( "alpha", visibility, 0 )
if ply:GetActiveWeapon():GetClass() == "gmod_tool" then
ply:DrawWorldModel( false ) -- tool gun has problems
else
ply:DrawWorldModel( true )
end
end
hook.Add( "Think", "InvisThink", doInvis )
else
ply:SetRenderMode( RENDERMODE_NORMAL )
ply:Fire( "alpha", 255, 0 )
ply:GetActiveWeapon():SetRenderMode( RENDERMODE_NORMAL )
ply:GetActiveWeapon():Fire( "alpha", 255, 0 )
ply:GetTable().invis = nil
end
end
[/CODE]
Here is how ULib does it's stealth.
Sorry, you need to Log In to post a reply to this thread.