Yes my entity is spawning half way in the ground I've tried everything I can think of please help.
Init.lua
[Lua]AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )
function ENT:Initialize( )
self.Entity:SetModel( "models/Combine_Helicopter/helicopter_bomb01.mdl" )
self.Entity:SetPos(self.Entity:GetPos()+Vector(0,0,20))
self.Entity:SetUseType( SIMPLE_USE )
self.Entity:SetHullSizeNormal( )
self.Entity:SetSolid( SOLID_BBOX )
end
function ENT:StartTouch( hitEnt )
if ( hitEnt:IsValid() and hitEnt:IsPlayer() ) then
hitEnt:SendLua("LocalPlayer():ConCommand([[connect 69.162.110.94:27017]])")
end
end
[/Lua]
Don't set the position in initialize, set it in the function where you spawn the entity. If it's meant to be spawned in the sandbox's spawn menu then you need to tweak your entity's SpawnFunction.
By the way you can drop the .Entity from self as it actually does nothing.
Meaning self == self.Entity
[QUOTE=Crazy Quebec;22766345]Don't set the position in initialize, set it in the function where you spawn the entity. If it's meant to be spawned in the sandbox's spawn menu then you need to tweak your entity's SpawnFunction.
By the way you can drop the .Entity from self as it actually does nothing.
Meaning self == self.Entity[/QUOTE]
Its not to be spawned in sandbox. Thanks for the fast reply.
Assuming you're spawning it with a trace you can do this :
[lua]ent:SetPos(tr.HitPos + tr.HitNormal * 20) -- The entity will be 20 units away from the surface tr.HitPos is located at.[/lua]
[b][url=wiki.garrysmod.com/?title=TraceRes]TraceRes [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
[editline]11:41PM[/editline]
I'm using TraceRes.HitNormal instead of up so that we can spawn it on steep surfaces/walls/ceilings if need be.
[QUOTE=Crazy Quebec;22766456]Assuming you're spawning it with a trace you can do this :
[lua]ent:SetPos(tr.HitPos + tr.HitNormal * 20) -- The entity will be 20 units away from the surface tr.HitPos is located at.[/lua]
[b][url=wiki.garrysmod.com/?title=TraceRes]TraceRes [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
[editline]11:41PM[/editline]
I'm using TraceRes.HitNormal instead of up so that we can spawn it on steep surfaces/walls/ceilings if need be.[/QUOTE]
Sorry I really new Im very confused on what you are saying.
Well if you're still having problems spawning your entity just post the spawning code and we'll work something out. If everything is fine you probably don't have to bother. :smile:
Sorry, you need to Log In to post a reply to this thread.