1
AddCSLuaFile()
DEFINE_BASECLASS( "base_anim" )
if SERVER then
function ENT:Initialize()
self.Entity:SetModel( "models/props_junk/harpoon002a.mdl" )
self.Entity:SetLagCompensated( true )
self.Entity:PhysicsInit( SOLID_VPHYSICS )
self.Entity:SetMoveType( MOVETYPE_VPHYSICS )
self.Entity:SetCollisionGroup( COLLISION_GROUP_NONE )
self.Phys = self.Entity:GetPhysicsObject()
if self.Phys:IsValid()
then
self.Phys:Wake()
end
end
elseif CLIENT then
function ENT:Initialize()
if self.Emission then
ParticleEffectAttach( self.Emission, PATTACH_POINT_FOLLOW, self, 0 )
end
end
end
function ENT:PhysicsCollide( data, phys )
timer.Simple(0, function()
self:OnCollide( data, phys )
end)
return true
end
function ENT:OnCollide( data, phys )
local Victim = data.HitEntity
if SERVER && data.HitEntity && data.HitEntity:IsWorld()
then
local Ang = self:GetAngles()
local Effect = EffectData()
Effect:SetAngles( Ang )
Effect:SetOrigin( self:GetPos() + Ang:Forward()*32 )
util.Effect("oce_pseudo_impact",Effect)
end
self:Remove()
end
Could you turn off collision with players via Physics and then do a function ENT:StartTouch(ent) then put your if then statements in there for damage?
Best way is to probably use a series of traces. There are multiple examples of this on the workshop. TFA is a good example.
It is not what I am searching for. Traces are expensive enough and I avoid to use them. Also traces should somehow predict the projectile's flying direction, which is not always straight and narrow. Thanks for your advice, but I think if physics engine already allows us to do stuff on collision, there is no need to add your own collision check.
It's in one of the tutorials I watched by Code Blue where he makes the coins you can pickup - right here:
https://youtu.be/Kr3xM6sgduA
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_NONE)
self:SetSolid(SOLID_VPHYSICS)
self:SetColor(Color(255,255,0))
This will make it so your entity cannot be collided by a player entity but can be collided by world entities such as walls and the like.
It finally helped me, thanks. This video was very helpful, I've attained my goal.
Sorry, you need to Log In to post a reply to this thread.