I’ve been working on a gamemode for the past few days, its supposed to mock STALKER.
I have the inventory laid out, and now I’m working on the functionality of it all.
I have my inventory panel, which is a frame with a “PanelList” inside it. I have it setup so that when i click a spawn icon, it will bring up a menu (if you’ve played stalker, when you right click it brings up a menu, and you can proceed to do whatever with the selected object, thats what I’m trying to recreate), with a few options.
The option I’m working on is dropping items out of your inventory. The only way i can see this happening is if I pass the model of the SpawnIcon to this function:
local ent = ents.Create("prop_physics") local phys = ent:GetPhysicsObject() local traceRes = LocalPlayer():GetEyeTraceNoCursor() ent:SetModel(a) ent:SetPos(traceRes["HitPos"]+Vector(0,0,5)) ent:SetMoveType(MOVETYPE_VPHYSICS) ent:Spawn() phys:Wake() phys:EnableGravity(true) phys:EnableMotion(true)
(Eventually i will make the dropping of the item more pretty by making it seem like you toss it in front of you, but for now, using an EyeTrace will suffice.)
The problem arises when it hits “Wake().”
It creates the model at the specified vector(which i think is the entity, but it doesn’t move or collide), awesome. But it gives me this error:
cl_init.lua:196: Tried to use invalid object (type IPhysicsObject) (Object was NULL or not of the right type)
(Line 196 points to: phys:Wake() under the drop_item function)
I’m not really understanding what the problem is here, any and all help would be appreciated.
I understand that if it were NULL, it doesn’t exist. But the mesh shows up, so wouldn’t that mean that the prop was created? And if its the wrong type, what other “types” are there?