Page 1 of 1

HowTo: Attach an Effect to an Object W/O Hardpoints (FAQ)

Posted: Sun Sep 30, 2007 10:33 am
by Ace_Azzameen_5
Ever wanted to attach an effect to an object, but it didn't have a hard point, or hard point where you wanted it to be? Just want the effect on one object?
Don't want to mass with effect spawner mshs?

Well, here's a solution using some of the games lua commands an the particle editor.
Its all based on these two simple lines of code:

Code: Select all

FecLoc = GetEntityMatrix("bes2_bldg_street_lamp17")
AttachEffectToMatrix(CreateEffect("blue_light"), FecLoc)
This is my code to attach a custom effect to the Bespin street lantern.
Obviously "bes2_bldg_street_lamp" is the ODF and "blue_light" is the FX file.
Note the LUA specifies an instance of the object, in ZE, and not just the ODF.


Get your own effect and Object, place this in your LUA under ScriptPostLoad, and you'd be done...but the problem is, the game isn't loading your effect. Check, and you'll see it is munged, but still not in game. For some reason, you have to create an object - odf and msh - that references your effect. It has to have hard points. Sneak it somewhere in your map. The effects will then be loaded.
Heres an example of 'REQ Object'
EffectReq.odf
Hidden/Spoiler:
[code]
[GameObjectClass]

ClassLabel = "prop"
GeometryName = "dag1_prop_grandtree_4.msh"


[Properties]

GeometryName = "dag1_prop_grandtree_4"

AttachToHardPoint = "hp_branch"

AttachOdf = "dag1_prop_leafpatch"

AttachEffect = "blue_light"

AttachToHardPoint = "hp_dryice1"

AttachEffect = "yellow_light"

AttachToHardPoint = "hp_fireflies1"

AttachEffect = "fireflies"

AttachToHardPoint = "hp_fireflies2"

AttachEffect = "fireflies"

AttachToHardPoint = "hp_fireflies3"

FoleyFXGroup = "wood_foley"
[/code]
O.K. Now you're effect is in game and attached to the object. Just one problem....its in the totally wrong place. Now, their are two ways to fix this, editing the FX's offests using particle editor, and using the Effect Path method.

1. Particle Editor:
Follow the Particle Editor Tutorial, and then open your effect. Expand each section of the effect, and repeat these steps: Click on 'Spawner'. Alter the series of boxes under 'Offset' to your preference. To stop the effect from 'wobbling' keep the min and max values the same.
Particle Editor Reference ScreenShot
Hidden/Spoiler:
Image
What are your preferences? Just mess around in here until effect is where you want it in game.

2. The effect Path Method.
Place a path, with one node, in ZE where you want the Effect to originate. Then, use this code instead of the above.

Code: Select all

FecLoc = GetPathPoint("Effect_Path", "node 0")
AttachEffectToMatrix(CreateEffect("Effect_Name"), FecLoc)
Note: FecLoc is just a chosen variable name, you could call them both "CheeseCube", as long as they were the same and not already being used.
Note2: Unfortunately, in trying to loop through an entire path, adding an effect to each node, I noticed that it looks like the "node_#" info is sort of...ignored.

And that concludes this tutorial. I hope this is useful to someone and hasn't already been mentioned (or tut-ified at least) on GT.

Feed back welcome, be specific.

Re: HowTo: Attach an Effect to an Object W/O Hardpoints

Posted: Sun Sep 30, 2007 12:25 pm
by t551
Can't you just use an .odf to attach the effect to the DummyRoot, and then offset it?

Although with this method, you could turn the effect on and off, and move it around, so that's cool.

Re: HowTo: Attach an Effect to an Object W/O Hardpoints

Posted: Sun Sep 30, 2007 12:43 pm
by Ace_Azzameen_5
Yes, without using separate objects, objects which are annoyingly limited in number.

Re: HowTo: Attach an Effect to an Object W/O Hardpoints

Posted: Sun Sep 30, 2007 3:25 pm
by trainmaster611
Very interesting discovery, I might have to use it.

Re: HowTo: Attach an Effect to an Object W/O Hardpoints

Posted: Sun Sep 30, 2007 3:34 pm
by wazmol
thanks ace for the tutorail!

-Wmol

Re: HowTo: Attach an Effect to an Object W/O Hardpoints

Posted: Mon Oct 01, 2007 3:59 am
by Frisbeetarian
In both instances, couldn't you combine the lines of code into one and skip using "fecloc" altogehter?

Re: HowTo: Attach an Effect to an Object W/O Hardpoints

Posted: Mon Oct 01, 2007 3:16 pm
by Ace_Azzameen_5
That didn't work for me, but I haven't tried it now that I got the system working completely. It may have been another bug.
So

Code: Select all

AttachEffectToMatrix(CreateEffect("Effect_Name"), GetPathPoint("Effect_Path", "node 0"))
--or
AttachEffectToMatrix(CreateEffect("Effect_Name"), GetEntityMatrix("LOLanOBJECT"))

Re: HowTo: Attach an Effect to an Object W/O Hardpoints (FAQ

Posted: Wed Jul 23, 2014 4:02 pm
by GAB
Bumping to contribuite with something...
Ace_Azzameen_5 wrote:Note2: Unfortunately, in trying to loop through an entire path, adding an effect to each node, I noticed that it looks like the "node_#" info is sort of...ignored.
It is actually possible to loop through an entire path and add an effect to each node. If you use the following command,

Code: Select all

AttachEffectToMatrix(CreateEffect("effect_name"),GetPathPoint("path_name", X))
where the X in the end of the command is the number of the node, you can attach an effect to any node within a path.

So, for example, you have a path with 5 nodes, going from Node 0 to Node 4, and want to attach an effect to Node 1, Node 2 and Node 4 (the 2nd, 3rd and 5th nodes respectively) you'd have:

Code: Select all

AttachEffectToMatrix(CreateEffect("effect_name"),GetPathPoint("path_name", 1)) 
AttachEffectToMatrix(CreateEffect("effect_name"),GetPathPoint("path_name", 2))
AttachEffectToMatrix(CreateEffect("effect_name"),GetPathPoint("path_name", 4))
And remember, the first node in a path is always named Node 0 (not Node 1).