I need to place a bank from the soda near the front of the Soda Mahine
I do it this way:
local pos = self:GetPos()
local ang = self:GetAngles()
prop:SetPos(pos + Vector(-10, 2, -24))
prop:SetAngles(ang + Angle(0, 0, 90))
prop:Spawn()
It would seem that the soda is located correctly.
https://files.facepunch.com/forum/upload/269653/f35269ce-1dd0-4ece-8b07-d9584b50a075/image.png
https://files.facepunch.com/forum/upload/269653/a1147962-8a95-4f08-8afc-bfeca15a7385/image.png
But when I turn the soda machine 360 degrees. Soda appears already on the reverse side
https://files.facepunch.com/forum/upload/269653/06d9aeb8-b4c4-4c29-8c4b-3a77a2c0ec0a/image.png
How to fix this?
Don't add a raw vector, use something like + ang:Forward() * 20, or whatever. Just keep playing with that number.
The reason this is happening is because right now, you're telling it to spawn a specified number of units in a certain direction, instead of always in front of the machine.
Thanks! What about the position of y and z?
Use Entity/LocalToWorld and Entity/LocalToWorldAngles
Call the functions on the vending machine entity to get the position and angle for the soda can:
prop:SetPos(vend:LocalToWorld(Vector(-10, 2, -24)))
prop:SetAngles(vend:LocalToWorldAngles(Angle(0, 0, 90)))
This also works great! Thanks for answers!
Sorry, you need to Log In to post a reply to this thread.