Dont know if this is the right place but i cant find a more appropriate place to post it.
Ive made a function that spawns props for a gamemode im working on, probleme is i want them spawned frozen, and i cannot get it to do that
so far i have:
[CODE]function SpawnProp(pos, angle, model, material, colour)
local ent1 = ents.Create("prop_physics")
print("Prop spawned with model: " .. model)
ent1:SetAngles(angle)
ent1:SetModel(model)
ent1:SetPos( pos )
ent1:SetColor(colour)
ent1:Spawn()
local l = ent1:GetPhysicsObject()
l:EnableMotion(false)
l:Sleep()
end[/CODE]
Can anyone spot any errors ive made? Obviously last 3 lines of the function are what's meant to be freezing them
(Also, im using it in gmod 13... if that makes a difference?)
[editline]19th August 2012[/editline]
nobody can help?
:c
[QUOTE=trotski94;37317121]Dont know if this is the right place but i cant find a more appropriate place to post it.
Ive made a function that spawns props for a gamemode im working on, probleme is i want them spawned frozen, and i cannot get it to do that
so far i have:
[CODE]function SpawnProp(pos, angle, model, material, colour)
local ent1 = ents.Create("prop_physics")
print("Prop spawned with model: " .. model)
ent1:SetAngles(angle)
ent1:SetModel(model)
ent1:SetPos( pos )
ent1:SetColor(colour)
ent1:Spawn()
local l = ent1:GetPhysicsObject()
l:EnableMotion(false)
l:Sleep()
end[/CODE]
Can anyone spot any errors ive made? Obviously last 3 lines of the function are what's meant to be freezing them
(Also, im using it in gmod 13... if that makes a difference?)
[editline]19th August 2012[/editline]
nobody can help?
:c[/QUOTE]
This worked for me in GM12:
[lua]
function SpawnProp(pos, angle, model)
local ent1 = ents.Create("prop_physics")
ent1:SetAngles(angle)
ent1:SetModel(model)
ent1:SetPos( pos )
ent1:Spawn()
local l = ent1:GetPhysicsObject()
if l and l:IsValid() then
l:EnableMotion(false)
print("Disabled motion")
end
if not ent1:IsValid() then return end
print("Prop spawned with model: " .. model)
end
[/lua]
That hasnt frozen it either... posted it as a bug in the gmod 13 forum.
Set the movetype to MOVETYPE_NONE.
Sleeping the physics of the entity will stop it from moving until it is woken up, which can be initiated by a few events- one example is with the physgun.
[QUOTE=zzaacckk;37328147]Set the movetype to MOVETYPE_NONE.
Sleeping the physics of the entity will stop it from moving until it is woken up, which can be initiated by a few events- one example is with the physgun.[/QUOTE]
tried that also... im starting to think it may just be gmod 13 itself.
[editline]20th August 2012[/editline]
So far i have this:
[CODE]
function SpawnProp(pos, angle, model, material, colour)
local ent1 = ents.Create("prop_physics")
ent1:SetAngles(angle)
ent1:SetModel(model)
ent1:SetPos( pos )
ent1:SetColor(colour)
ent:SetMoveType(MOVETYPE_NONE)
ent1:Spawn()
local l = prop:GetPhysicsObject()
if l and l:IsValid() then
l:EnableMotion(false)
print("Disabled motion")
end
if not ent1:IsValid() then return end
print("Prop spawned with model: " .. model)
end
[/CODE]
Still nothing...
EDIT: although it doesnt print 'Disabled motion' either, error with GetPhysicsObject?
Before putting an entity to sleep I always do this:
:SetVelocity( Vector(0, 0, 0) );
Might be of some use to you?
[QUOTE=trotski94;37331239][CODE] local l = prop:GetPhysicsObject()[/CODE][/QUOTE]
You don't have an entity "prop", that should be ent1 like you had in the previous code
You're also doing SetMoveType to ent, not ent1
You did set the movetype of variable 'ent', which isn't declared within that scope.
Try ent1 instead.
i know its abit later, but now i have this:
[CODE]function SpawnProp(pos, angle, model, material, colour)
local ent1 = ents.Create("prop_physics")
ent1:SetAngles(angle)
ent1:SetModel(model)
ent1:SetPos( pos )
ent1:SetColor(colour)
ent1:SetMoveType(MOVETYPE_NONE)
ent1:Spawn()
ent1:GetPhysicsObject():EnableMotion(false)
ent1:SetVelocity( Vector(0, 0, 0) );
local l = ent1:GetPhysicsObject()
if l:IsValid() then
l:EnableMotion(false)
l:sleep()
print("Disabled motion")
end
if not ent1:IsValid() then return end
print("Prop spawned with model: " .. model)
end
[/CODE]
This still doesnt freeze the props...
Sorry, you need to Log In to post a reply to this thread.