• Entity with Gravity / Stick to ground
    3 replies, posted
Hay, Just a short question, how can i make entities stick to the ground? So when i spawn them 20cm above the ground, they will fall to the ground? init.lua [LUA] AddCSLuaFile("cl_init.lua"); AddCSLuaFile("shared.lua"); include("shared.lua"); function ENT:Initialize ( ) self:SetSolid(SOLID_BBOX); self:PhysicsInit(SOLID_BBOX); self:SetMoveType(MOVETYPE_STEP); self:DrawShadow(true); self:SetUseType(SIMPLE_USE); end [/LUA]
[lua]self:SetSolid(SOLID_BBOX); self:PhysicsInit(SOLID_BBOX)[/lua] No and No. Use this: [lua]self:PhysicsInit(SOLID_VPHYSICS) self:SetMoveType(MOVETYPE_VPHYSICS) self:SetSolid(SOLID_VPHYSICS)[/lua] And remember to set a model.
Thanks, but they're still floating in the air, did i forget anything?
self:GetPhysicsObject():Wake() And for the sticking: [CODE] function ENT:StartTouch( ent ) if ent:IsWorld() then self:SetParent( ent ) self:SetMoveType( MOVETYPE_NONE ) end end [/CODE]
Sorry, you need to Log In to post a reply to this thread.