• SNPC - T-Pose after spawning
    4 replies, posted
Hey everyone, when recently attempting to make stationary NPC's, everything works including any function that is called when a player presses "E" on the NPC. The big problem here is that the NPC always spawns in the all so ugly T-Pose, I've tried a ton of ways to fix this. Used Player models, citizen models and basically every model I can find. This is the code I have if anyone could help; [b]Entity - Init[/b] [code]AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) include('shared.lua') function ENT:Initialize( ) self:SetModel("models/humans/group01/female_01.mdl") self:SetHullType( HULL_HUMAN ) self:SetSolid( SOLID_BBOX ) self:CapabilitiesAdd( bit.bor(CAP_ANIMATEDFACE, CAP_TURN_HEAD) ) self:SetUseType( SIMPLE_USE ) self:SetCollisionGroup( COLLISION_GROUP_PLAYER ) self:DropToFloor() self:SetMaxYawSpeed( 90 ) end function ENT:OnTakeDamage(dmg) if dmg:GetAttacker()~=nil and dmg:GetAttacker():IsPlayer() then self:SetTarget(dmg:GetAttacker()) dmg:GetAttacker():TakeDamage(dmg:GetDamage(),self) end return false end function ENT:AcceptInput( Name, Activator, Caller ) if Name == "Use" and Caller:IsPlayer() then if self["Func"]~=nil then self.Func(Activator) end end end[/code] [b]Entity - Shared[/b] [code]ENT.Base = "base_ai" ENT.Type = "ai" ENT.AutomaticFrameAdvance = true function ENT:SetAutomaticFrameAdvance( bUsingAnim ) self.AutomaticFrameAdvance = bUsingAnim end [/code] [b]Entity - cl_init[/b] [code]include('shared.lua')[/code] And finally [b]Map Spawning[/b] [code]function GM:InitPostEntity() CGRP.AddNPC = function(pos, ang, mdl, func) local TNPC = ents.Create("cgrp_npc") TNPC:SetPos( pos + Vector(0,0,10) ) TNPC:SetAngles( ang ) TNPC:Spawn() TNPC:DropToFloor() if func~=nil then TNPC["Func"]=func end TNPC["Model"]=mdl if IsValid(TNPC) then TNPC:SetModel(TNPC["Model"]) end end if string.lower(game.GetMap())=="rp_rockford_beta" then CGRP.AddNPC(Vector(-4459,-5348,64),Angle(0,-90,0),"models/humans/group01/female_01.mdl",function(ply) ply:PrintMessage(HUD_PRINTTALK,"Hey there") end) end if string.lower(game.GetMap())=="rp_evocity_v2d" then CGRP.AddNPC(Vector(-6748,-9421,136),Angle(0,-90,0),"models/humans/group01/female_01.mdl",function(ply) ply:PrintMessage(HUD_PRINTTALK,"Hey there") end) end end[/code] I am completely lost as to where the problem would be, it spawns perfectly fine and functions well. Just the T-Pose is irritating as hell. Thanks in advanced - Stevob21!
Usually means you're using a model that's not rigged to be a npc.
You should use next_bot when you create your entity in your CGRP.AddNPC function and change his base in your gamemode like this: [lua] function TNPC:OnTakeDamage(dmg) --do stuff end [/lua] Not sure how to answer your original problem but I'd suggest you use next_bot as SNPCs I assume will be deprecated in the near future. You can refer to next_bot use on the gwiki and this thread [URL="http://www.facepunch.com/showthread.php?t=1260326"]http://www.facepunch.com/showthread.php?t=1260326[/URL]
self:SetModel("models/humans/group01/female_01.mdl") Should be: self:SetModel("models/player/group01/female_01.mdl") Replace humans with player. Humans are ragdolls, playermodels are different. Not sure if that's the exact path, but yours is the wrong one. This applies to human players as well. Don't set a player's model to a ragdoll.
If you are unsure about the path to the player models, here's a list including all of GMODs player models [url]https://github.com/garrynewman/garrysmod/blob/master/garrysmod/lua/includes/modules/player_manager.lua[/url]
Sorry, you need to Log In to post a reply to this thread.