• Making a prop follow you
    6 replies, posted
Hey is a it possible to create a scripted entitie that is a prop and it just follows you around? If anyone can help me that would be great!
I believe you would use something along the lines of. local proppos = LocalPlayer():GetPos() - Vector( 20, 20, 0) entity:SetPos(proppos) (Off the top of my head probably wrong but it's worth a try :D )
[QUOTE=noforgivin;20152913]I believe you would use something along the lines of. local proppos = LocalPlayer():GetPos() - Vector( 20, 20, 0) entity:SetPos(proppos) (Off the top of my head probably wrong but it's worth a try :D )[/QUOTE] Mhm doesn't really help me :P
well that would make it follow you... If you dont know how to spawn a prop entiity go look on the wiki.
Look at how he did it. [url]http://www.facepunch.com/showthread.php?p=20146182#post20146182[/url]
[code]AddCSLuaFile ("cl_init.lua") AddCSLuaFile ("shared.lua") include ("shared.lua") resource.AddFile("particles/smoke.pcf") function ENT:Initialize() self.Entity:SetModel ("models/Gibs/HGIBS.mdl") self.Entity:PhysicsInit(SOLID_VPHYSICS) self.Entity:SetMoveType(MOVETYPE_VPHYSICS) self.Entity:SetSolid(SOLID_VPHYSICS) self.PhysObj=self.Entity:GetPhysicsObject() if(self.PhysObj:IsValid()) then self.PhysObj:EnableGravity(false) self.PhysObj:Wake() end end ENT.OurHealth = 100 function ENT:Use( activator, caller ) self.Target = activator end function ENT:SpawnFunction ( ply,tr ) if not tr.HitWorld then return end local ent = ents.Create("construct") ent:SetPos(tr.HitPos + Vector(0,0,50)) ent:Spawn() ent.Target = ply return ent end function ENT:OnTakeDamage(dmg) self.Entity:TakePhysicsDamage(dmg) if dmg:GetAttacker():IsPlayer() then self.angry = true end end function ENT:Think() if ValidEntity(self.Target) then if self.angry then if not self.Target:Alive() then self.angry = false ParticleEffectAttach("smoke",PATTACH_ABSORIGIN_FOLLOW,self,0) end local eyes = self.Target:LookupAttachment("eyes") local pos = self:GetPos() local tpos = self.Target:GetAttachment(eyes).Pos local vec = (tpos - pos) local ang = vec:Angle() self:SetAngles(ang) local vecnorm = vec:GetNormal() local phys = self:GetPhysicsObject() phys:AddAngleVelocity (phys:GetAngleVelocity()*-1) phys:ApplyForceCenter(vec * 170 * phys:GetMass()) phys:SetVelocity(phys:GetVelocity() + Vector(0,0,2*math.cos(4*CurTime()))) end elseif ValidEntity(self.Target) then local eyes = self.Target:LookupAttachment("eyes") local pos = self:GetPos() local tpos = self.Target:GetAttachment(eyes).Pos local vec = (tpos - pos) local ang = vec:Angle() self:SetAngles(ang) local vecnorm = vec:GetNormal() local phys = self:GetPhysicsObject() phys:AddAngleVelocity (phys:GetAngleVelocity()*-1) if vec:Length() >= 170 then phys:ApplyForceCenter(vecnorm * 170 * phys:GetMass()) elseif vec:Length() > 40 then phys:ApplyForceCenter( vec * phys:GetMass()) end phys:SetVelocity(phys:GetVelocity() + Vector(0,0,2*math.cos(4*CurTime()))) end end[/code] How would I turn it into a prop that is on the ground?
This should be in requests as you clearly dont want to do it your self, but if you do then read some lua tutorials first.
Sorry, you need to Log In to post a reply to this thread.