Hello, so I'm working on an entity and well, while i have 2 'fake entities' from made in 1 entity they always messup on spawn. What I mean by this is if i face North, spawn the entity they spawn correctly, but if i face West the angles go all off set.
This is an example of what I mean.
[IMG]http://image.prntscr.com/image/e38387e6804041da82886a15399dd22f.png[/IMG]
Hopefully someone will save me from this annoying issue ;\
Code.
[LUA]
function ENT:Initialize()
self:SetModel("models/hunter/blocks/cube075x3x075.mdl") -- the part where shit slides down on when paying
self:SetRenderMode(RENDERMODE_TRANSALPHA)
self:SetSolid( SOLID_VPHYSICS )
self:SetColor(Color(255,255,255,5))
self:SetMoveType( MOVETYPE_NONE )
self:SetCollisionGroup( COLLISION_GROUP_WEAPON )
self:PhysicsInit( SOLID_VPHYSICS )
self:SetUseType( SIMPLE_USE )
self:DropToFloor()
self.cashtable = ents.Create("prop_physics")
self.cashtable:SetModel("models/hunter/blocks/cube075x1x075.mdl")
self.cashtable:SetColor(0,0,0)
self.cashtable:SetMoveParent( self.Entity )
self.cashtable:SetAngles(Angle(0, 110 , 0) )
self.cashtable:SetPos(self.Entity:GetPos() + Vector(0,100,0)) -- cash register goesontop of here
self.cashreg = ents.Create("prop_physics")
self.cashreg:SetModel("models/props_c17/cashregister01a.mdl") -- Cash register
self.cashreg:SetColor(0,0,255, 100)
self.cashreg:SetMoveParent( self.Entity )
self.cashreg:SetAngles(Angle(0, 230 , 100) )
self.cashreg:SetPos(self.cashtable:GetPos() + Vector(100,0,0))
--models/hunter/blocks/cube075x1x075.mdl
local phys = self:GetPhysicsObject()
if IsValid( phys ) then
phys:Wake()
end
end
[/LUA]
No code, No help
[editline]6th October 2016[/editline]
[url]http://wiki.garrysmod.com/page/Global/LocalToWorld[/url]
[lua]self.cashtable:SetAngles(self:LocalToWorldAngles(Angle(0, 110 , 0)))
self.cashtable:SetPos(self:LocalToWorld(Vector(0,100,0)))[/lua]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/LocalToWorld]Entity:LocalToWorld[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/LocalToWorldAngles]Entity:LocalToWorldAngles[/url]
[editline]6th October 2016[/editline]
Alternatively, set the position and angles before setting the parent like in the example here [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetMoveParent]Entity:SetMoveParent[/url]
[QUOTE=NeatNit;51160595][lua]self.cashtable:SetAngles(self:LocalToWorld(Angles(Angle(0, 110 , 0)))
self.cashtable:SetPos(self:LocalToWorld(Vector(0,100,0)))[/lua]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/LocalToWorld]Entity:LocalToWorld[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/LocalToWorldAngles]Entity:LocalToWorldAngles[/url]
[editline]6th October 2016[/editline]
Alternatively, set the position and angles before setting the parent like in the example here [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetMoveParent]Entity:SetMoveParent[/url][/QUOTE]
LocalToWorld returns both angles and pos.
the global one does, not the entity one
[editline]6th October 2016[/editline]
Unless it does, in which case please confirm in-game and update the wiki :happy:
[QUOTE=NeatNit;51160701]the global one does, not the entity one
[editline]6th October 2016[/editline]
Unless it does, in which case please confirm in-game and update the wiki :happy:[/QUOTE]
Ok, I thought it's the global one. My bad.
[QUOTE=NeatNit;51160595][lua]self.cashtable:SetAngles(self:LocalToWorld(Angles(Angle(0, 110 , 0)))
self.cashtable:SetPos(self:LocalToWorld(Vector(0,100,0)))[/lua]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/LocalToWorld]Entity:LocalToWorld[/url]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/LocalToWorldAngles]Entity:LocalToWorldAngles[/url]
[editline]6th October 2016[/editline]
Alternatively, set the position and angles before setting the parent like in the example here [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/SetMoveParent]Entity:SetMoveParent[/url][/QUOTE]
Angles is nil value? owo
I had a typo, fixed it now
Sorry, you need to Log In to post a reply to this thread.