Particle positioning?

I’ve got a small weapon I’m working on and I recently tried to get some particle effects to shoot from it. The swep returns no errors but particles only appear at a fixed point on the map.

Here is the code I added that produced this.

a =Vector(self.Owner:GetPos())
b =Vector(self.Owner:EyePos())
local pt = util.ParticleTracerEx( "vortigaunt_beam", a, b, true, self.Owner:EntIndex(), 1 )

It’s supposed to start at the owners position, then end at the aim vector of the owner. But it’s just kinda chilling there like silly particles man.

Entity:EyePos() returns the player’s view position. Your start point (a) needs be the position of the weapon’s muzzle, or perhaps

Player:GetShootPos, and your end point (b) needs to be the HitPos, which can be done with self.Owner:GetEyeTrace().HitPos if your weapon doesn’t already determine the hit vector.

Swag. Thank you based coder

The particles still appear to be showing at only 1 point of the map.

I tried different particle effects and all came up at the same position

Post the code you’re currently using for this and I’ll have a look.

Thanks

You are passing the arguments to

util.ParticleTracerEx in the incorrect order

It expects:
string name
Vector startPos
Vector endPos
number entityIndex
boolean doWhiz
number attachmentIndex

You are giving it:
string “env_fire_random_puff”
Vector a
Vector b
boolean true
number self.Owner:EntIndex()
number 1

Swap the order of true and self.Owner:EntIndex() in line 27

Doing that only returned this.

[ERROR] lua/weapons/laser smg/shared.lua:107: bad argument #5 to ‘ParticleTracerEx’ (number expected, got boolean)

  1. ParticleTracerEx - [C]:-1
  2. unknown - lua/weapons/laser smg/shared.lua:107

Maybe the wiki is wrong then. But you do realise the two points you are passing it are only 1 unit apart?

Actually I didnt, but I’m more concerned about getting it to show up in the right place.

Does it look correct in third person? (sv_cheats 1, thirdperson)

No, switching self.Owner:EntIndex() and true are the only way I can get it to show up, and it still only appears at 1 point on the map.

Looks like the wiki’s arg order is wrong. I’ll test it later and change it accordingly.

I did find this on the old wiki:

Not sure how relevant that still is, but have you tried it with some other particle systems?

[editline]extra[/editline] The old wiki article has the args in the correct order, too.

[editline]6th March 2015[/editline]

I’ve just tested the following line of code ingame:



util.ParticleTracerEx( "vortigaunt_beam", self.Owner:GetShootPos(), self.Owner:GetEyeTrace().HitPos, true, self.Owner:EntIndex(), 1)


It would seem to work fine both serverside and clientside.

Having a look at your pastebin code, I’ve noticed you’re wrapping your inputs with Vector(). I bet this is what’s breaking your positions. Try this:



local a = self.Owner:GetShootPos()
local b = self.Owner:GetShootPos() + self.Owner:GetAimVector() * 32768


You might want to use HitPos for b if running this both clientside and serverside, since other clients won’t be looking straight down the traceline.

Yeah wrapping them with vector seemed to be whats breaking them. Thanks!