• How to change a particles position in ParticleEffectAttach()
    3 replies, posted
Hello so I am currently trying to test out particles in my addon and I want to have a water falling effect. However I want to attach it to an entity and then have it move with that entity. I managed to get that working by using this in init.lua: ParticleEffectAttach("pp_water", PATTACH_POINT_FOLLOW, self, 0) However I can't set the position of the particle within this function, it just spawns at the entitys origin every time. I also attempted this, but you can't set it to follow as far as I know: ParticleEffect("pp_water", self:GetPos() + self:GetAngles():Up() * 10, self:GetAngles(), self) And finally I tried to use Entity:CreateParticleEffect() in cl_init.lua: self:CreateParticleEffect("pp_water", 0, {PATTACH_POINT_FOLLOW, self, self:GetPos() + self:GetAngles():Up() * 40}) However in the gmod wiki documentation it says I need to use a table for the third parameter and as you can see I attempted that however it does not work, it just sets it to the defaults as listed on the gmod wiki page for the function. So can someone help me to have it both attach and have a custom position relative to the entity?
The reason the particle effect reverts to The entity has to have attachments that the particle effect can start on. Also, attachment ids start at 1 I'm pretty sure. For example, these are the attachments on a portal gun. https://files.facepunch.com/forum/upload/295351/c82cc257-113d-4fc9-a427-4b806bb5c3b2/helper.png Using this, you can use it in a weapon to show custom muzzle effects: local vm = self.Owner:GetViewModel() ParticleEffectAttach("portalgun_muzzle", PATTACH_POINT, vm, vm:LookupAttachment("muzzle")) Or in your case, a water fall particle effect. You'll have to make the water particles fall in the particle effect, since you can't affect individual particles in the code. // Waterfall entity with specific attachment ParticleEffectAttach("pp_water", PATTACH_POINT, vm, vm:LookupAttachment("water_spout")) To actually create an attachment point in your model, your model needs at least 1 bone to attach your attachment to. Now when you're done with putting the bone, you'll have to create the attachment itself. $attachment (name) (bone name) (X) (Y) (Z) ["absolute"] ["rigid"] ["rotate" pitch yaw roll] Now a little explanation: (name) is the name of the attachment. In the example above the one above, the attachment is called water_spout. (bone name) is the name of the bone you're going to attach to. (X) (Y) (Z) is the position of the attachment relative to the bone. You can actually adjust this in HLMV.exe, found in GarrysMod/bin. https://files.facepunch.com/forum/upload/295351/a28ab60b-1cf9-4488-b366-45e783164c23/1.PNG absolute makes the attachment relative to the origin, not bone. (To Do: this is a guess, i may be wrong) rigid is nothing I know. Could someone give me some insight? rotate 0 0 0 the rotation of the attachment. You can also adjust in HLMV.exe. You can find more on attachments here.
CreateParticleEffect doesn't work for you because you used it wrong. It doesn't take any random table, it takes a table with specific KEYS inside it, as it is documented on the wiki.
Thanks for the responses guys, however I actually did manage to get what I wanted to happen using this funciton clientside: CreateParticleSystem(self, "pp_malt", PATTACH_ABSORIGIN_FOLLOW, 0, (self:GetAngles():Up() * -33) + (self:GetAngles():Right() * -50) + (self:GetAngles():Forward() * -5)) If this is somehow an inefficent way though or there is a reason why i shouldnt use the above method then I am open to adding the attachments to my custom model as I already have bones in place at my desired location. Also in response to Rubat could you explain how I would then properly use that function as im still confused on it, although it may not be necessary to know that now since I can use the other methods.
Sorry, you need to Log In to post a reply to this thread.