I’ve made a simple entity:
AddCSLuaFile()
ENT.Base = "base_anim"
function ENT:Initialize()
self:SetModel( "models/props_junk/cardboard_box001a.mdl" )
self:SetCollisionGroup( COLLISION_GROUP_WORLD )
self:CollisionRulesChanged()
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
self:PhysicsInit( SOLID_VPHYSICS )
self:GetPhysicsObject():Wake()
end
function ENT:SetPhysVelocity( vel )
self:SetVelocity( vel )
local phys = self:GetPhysicsObject()
if IsValid( phys ) then
phys:SetVelocity( vel )
end
end
And i’m creating this entity whit following code:
local ent = ents.Create( "test_ent" )
if IsValid( ent ) then
ent:SetPos( self.Owner:GetPos() + self.Owner:GetAngles():Forward() * 50 + Vector( 0, 0, 50 ) )
ent:Spawn()
ent:Activate()
ent:SetPhysVelocity( self.Owner:GetAngles():Forward() * 150 )
end
And my problem is that when I spawn this entity, instead of entity that dynamic moves forward and down, I’m getting falling straight down entity which teleports forward 1 second after it touchs ground. What am I doing wrong?
Sorry if my English is bad.