triggers, emitters and new AIPlayer class
by Chris Cacatian · in Torque 3D Professional · 11/13/2009 (10:54 pm) · 1 replies
maybe this isn't the best way to do this, but I was trying to get an emitter on the AIPlayer. Not a specific section, just a general area emitter, like the footPuffEmitter. Anyways, I need to be able to change this emitter to another emitter, and possibly edit some emitter settings, during scripting.
First, after adding triggers 1, 2 to a run animation in the shape editor, I could use the footPuffEmitter to show particles as he walked on the ground. But changing the emitter through script changed the emitter for all objects on the screen. I'm guessing that's because all it did was change which footPuffEmitter the PlayerData was storing, and that's shared data, instead of unique between Players.
After that, I tried to create 2 different datablocks, only changing which footPuffEmitter was being used. I tried to change the datablock during script outside of the spawn function, but it crashed. Apparently I'm not supposed to be able to change the datablock outside of new AIPlayer() {}.
So, my latest attempt was to create a new AIPlayer class. I made a copy of AIPlayer, renamed it to AIPlayerCopy and added ParticleEmitterData. I didn't use a pointer because I wanted to be able to tweak emitter settings and keep those tweaks to the individual, instead of tweaking the actual ParticleEmitterData. I also created a updateActionThread(), which calls the parent's updateActionThread and also handles my emitter. I used something similar to the footpuff emitter's code for my emitter.
Here's where the problem lies...the animation trigger doesn't get called. Not in my AIPlayer class anyways. I've setup breakpoints and the trigger breakpoint is never set, yet, the same trigger is called in the Player's updateActionThread().
I have had the parent updateActionThread() called before and after my emitter code, and nothing seems to work. I'm currently using trigger 3 (the footPuffEmitter used 1 and 2 for left and right foot). I noticed that the animation sequence needs to be called "run" for it to work.
I think in the end, I will be making my own AIPlayer class, because it will be game specific and I don't want add game specific code into the engine.
What am I doing wrong here? Is there something that I need to add to get the trigger to work w/ my new class? Or am I just going about this all wrong?
Thanks in advance,
Chris
First, after adding triggers 1, 2 to a run animation in the shape editor, I could use the footPuffEmitter to show particles as he walked on the ground. But changing the emitter through script changed the emitter for all objects on the screen. I'm guessing that's because all it did was change which footPuffEmitter the PlayerData was storing, and that's shared data, instead of unique between Players.
After that, I tried to create 2 different datablocks, only changing which footPuffEmitter was being used. I tried to change the datablock during script outside of the spawn function, but it crashed. Apparently I'm not supposed to be able to change the datablock outside of new AIPlayer() {}.
So, my latest attempt was to create a new AIPlayer class. I made a copy of AIPlayer, renamed it to AIPlayerCopy and added ParticleEmitterData. I didn't use a pointer because I wanted to be able to tweak emitter settings and keep those tweaks to the individual, instead of tweaking the actual ParticleEmitterData. I also created a updateActionThread(), which calls the parent's updateActionThread and also handles my emitter. I used something similar to the footpuff emitter's code for my emitter.
Here's where the problem lies...the animation trigger doesn't get called. Not in my AIPlayer class anyways. I've setup breakpoints and the trigger breakpoint is never set, yet, the same trigger is called in the Player's updateActionThread().
I have had the parent updateActionThread() called before and after my emitter code, and nothing seems to work. I'm currently using trigger 3 (the footPuffEmitter used 1 and 2 for left and right foot). I noticed that the animation sequence needs to be called "run" for it to work.
I think in the end, I will be making my own AIPlayer class, because it will be game specific and I don't want add game specific code into the engine.
What am I doing wrong here? Is there something that I need to add to get the trigger to work w/ my new class? Or am I just going about this all wrong?
Thanks in advance,
Chris
Torque 3D Owner Chris Cacatian
MXR International
The call stack says something about ghostReadPacket during the 2nd AIPlayer constructor call, which leads me to believe that it's creating the ghost "version" as well. The problem is, this "ghost" doesn't have it's emitter set when it is called in script (the other AIPlayer does).
So, I now I have 2 AIPlayers being created, but the "ghost" which handles the triggers correctly doesn't have an emitter.
How do I go about setting the emitter for the ghost? Does this have to do something w/ pack/unpackData()? Am I not allowed to store the emitter data in the AIPlayer class itself? If I have to use PlayerData, the problem with that seems to be that I would have to create PlayerData for each AIPlayer I create so that I can change the emitter on the fly w/out affecting the other instances.