• Making bullets aim at player/other targets
    10 replies, posted
    local helibullet = {}     helibullet.Num = 1     helibullet.Src = heli_npc:GetAttachment(heli_npc:LookupAttachment("Muzzle")).Pos     helibullet.Dir = Vector(heliturretarget)     helibullet.Spread = 0.2     helibullet.Tracer = 1     helibullet.TracerName = "Tracer"     helibullet.Force = 1     helibullet.Damage = 10     helibullet.AmmoType = "Ar2" I tried using PointAtEntity but it doesn't seem to work. So now heliturrettarget is heliturrettarget = dmginfo:GetAttacker():GetPos() Any way to make it work?
try (StartPos - EndPos):GetNormalized()
Aye, works great. Another question though, why won't the bullets damage players but damages everything else? Do I need to include something else?
I think the ammo type you've placed in isn't actually the correct one, I have no idea - If you use :FireBullets make sure you run it shared, not client only. http://wiki.garrysmod.com/page/Default_Ammo_Types Default ammo types - you got Ar2, should be AR2
That would make a lot of sense but shouldn't it just error out and not work at all? I'll try this in a sec and hopefully it works though.
If it's on client and you only run it on client, it just might look like you're shooting at them, and creating decals, but not actually dealing damage - What is your filename and what's your addon structure? If it interacts with NPCs, and is able to kill them, then it's running on shared, if it looks like they're bleeding but no damage is taken, then it's running on client only.
Its shared. Its able to kill NPCs and its created in autorun/ https://i.imgur.com/uP22zeK.png
Tried everything so far and it still does not work.
If it doesn't damage players check to make sure something like FPP isn't preventing NPCs from damaging players.
Just cause its shared, doesn't mean it has the same shared variables. 1) We don't have the code. All we can do is speculate and rub a crystal ball. 2) Debug the code. Use print on target, target-position, angle .. everything. Then compare the results of both server and client to see if they match. That is how I find 90% of all my bugs. 3) If the bullet shoots in the direction of the target. It works client-side. If the bullet damages the target. It works server-side. The two realms don't communicate much when handling bullets.
My apologies for the really late reply, but here's the code: if heli_npc:IsValid() then local HeliNPCEnemy = heli_npc:GetEnemy()   timer.Create("BulletFire", 0.154, 50, function()     sound.Play("weapons/tfa_ins2/fort500/toz_fp.wav", Vector(heli_npc:GetPos()), 90, 100, 1 )     sound.Play("weapons/tfa_ins2/minimi/m249-attack-far-distant.wav", Vector(heli_npc:GetPos()), 140, 75, 1 )     local helibullet = {}     helibullet.Spread = 3     helibullet.Tracer = 1     helibullet.TracerName = "AR2Tracer"     helibullet.Force = 10     helibullet.Damage = 20     helibullet.AmmoType = "AR2"     helibullet.Num = 1     helibullet.Range = 5555     helibullet.IgnoreEntity = heli_npc     helibullet.Src = heli_npc:GetAttachment(heli_npc:LookupAttachment("Spotlight")).Pos     if (heli_npc:GetEnemy() == rocketpos2) or (heli_npc:GetEnemy() == rocketpos) then return end     helibullet.Dir = (heli_npc:GetEnemy():GetPos() +heli_npc:GetEnemy():OBBCenter())-heli_npc:GetAttachment(heli_npc:LookupAttachment("Spotlight")).Pos   heli_npc:FireBullets(helibullet) end) else return end Atleast, a part of it. I'm using a timer just to test stuff out but the rest should be pretty obvious.
Sorry, you need to Log In to post a reply to this thread.