I just want to add my bullets an impact effect ( when the bullets hit something ), but it keeps spamming errors...
[CODE]
function SWEP:PrimaryAttack()
if ( !self:CanPrimaryAttack() ) then return end
local bullet = {}
bullet.Num = self.Primary.NumShots
bullet.Src = self.Owner:GetShootPos()
bullet.Dir = self.Owner:GetAimVector()
bullet.Spread = Vector( self.Primary.Cone , self.Primary.Cone, 0)
bullet.Tracer = 1
bullet.TracerName = "AirboatGunTracer"
bullet.Force = self.Primary.Force
bullet.Damage = self.Primary.Damage
bullet.AmmoType = (self.Primary.Ammo)
local hit1, hit2 = tr.HitPos + tr.HitNormal, tr.HitPos - tr.HitNormal
local effect = EffectData()
util.Effect("HelicopterImpact", effect)
self:ShootEffects()
self.Owner:FireBullets( bullet )
self:ShootEffects()
self.Owner:FireBullets( bullet )
self.Weapon:EmitSound(Sound(self.Primary.Sound))
self:TakePrimaryAmmo(1)
self.Weapon:SetNextPrimaryFire( CurTime() + self.Primary.Delay )
self.Weapon:SetNextSecondaryFire( CurTime() + self.Primary.Delay )
self.Weapon:SendWeaponAnim(ACT_VM_PRIMARYATTACK)
self.Owner:MuzzleFlash()
self.Owner:SetAnimation(PLAYER_ATTACK1)
end
[/CODE]
You're referring to tr, but it doesn't exist.
You're not actually tracing a line
you can do
[LUA]
local tr = util.QuickTrace( Vector origin, Vector direction, entity or table filter )
[/LUA]
[url]http://wiki.garrysmod.com/page/util/QuickTrace[/url]
[QUOTE=rejax;42541656]You're not actually tracing a line
you can do
[LUA]
local tr = util.QuickTrace( Vector origin, Vector direction, entity or table filter )
[/LUA]
[url]http://wiki.garrysmod.com/page/util/QuickTrace[/url][/QUOTE]
[CODE]
local trace = {}
trace.start = self.Owner:GetShootPos()
trace.endpos = self.Owner:GetShootPos() + self.Owner:GetAimVector() * 20^14
trace.filter = self.Owner
local tr = util.TraceLine(trace)
[/CODE]
Would that be ok too?
20^14 is an overkill considering source map size limit is 1024*32
Ok got it, thanks
Sorry, you need to Log In to post a reply to this thread.