Author Topic: [Solved] Rotating Emitters?  (Read 1484 times)

Hi BLF, this is a stupid question but how do I rotate emitters via script? Here's my emitter:

It's currently a vertical ring around my player. I want it to be a horizontal ring around my player. Is there a way to do this?

datablock ParticleData(HealerParticle)
{
   dragCoefficient      = 0;
   gravityCoefficient   = 0;
   inheritedVelFactor   = 0.15;
   constantAcceleration = 0.0;
   lifetimeMS           = 200;
   lifetimeVarianceMS   = 0;
   textureName          = "./Healer";
   colors[0]     = "0 0 0 1";
   sizes[0]      = 0.5;
   sizes[1]      = 0.6;
   times[0]      = 0.0;
   times[1]      = 1;
   useAlphaInv = false;
};
datablock ParticleEmitterData(HealerEmitter)
{
   ejectionPeriodMS = 1;
   periodVarianceMS = 0;
   ejectionVelocity = 0.0;
   velocityVariance = 0.0;
   ejectionoffset   = 1.0;
   thetaMin         = 89;
   thetaMax         = 91;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "HealerParticle";
   uiName = "Healer";
};
datablock ShapeBaseImageData(HealerImage)
{
   shapeFile = "base/data/shapes/empty.dts";
   emap = false;
   mountPoint = $backslot;
   stateName[0] = "Ready"; //This is first
   stateTransitionOnTimeout[0] = "loopStart"; //Name of state to go to next.
   stateTimeoutValue[0] = 0.1; //Seconds for it to go to the next part of the loop.

   stateName[1] = "loopStart"; //Name of the state
   stateTransitionOnTimeout[1] = "loopEnd"; //next state you go to
   stateTimeoutValue[1] = 0.1; //Seconds til the next part of the loop
   stateEmitter[1] = "healerEmitter"; //The emitted emitter datablock here.
   stateEmitterTime[1] = 1; //Time for the emitter to last, in seconds.

   stateName[2] = "loopEnd";
   stateWaitForTimeout[2] = 0;
   stateTransitionOnTimeout[2] = "loopStart";
   stateEmitterTime[2] = 1; //Emitter lifespan
   stateEmitter[2] = "healerEmitter";
   stateTimeoutValue[2] = 1;
};


Proof of Concept:
« Last Edit: June 27, 2016, 08:55:02 PM by Johnny Blockhead »

try rotating the healerimage by 90 degrees:
rotation = eulerToMatrix("0 0 90"); (try 90 in other slots too if it doesnt seem to work)

if not, muffinmix's guide should help, but it may be the case that your goal isnt possible with default emitters. I know of emitters that run in a circle around a brick horizontally, but it doesnt seem possible to run a ring vertically (except if you rotate the object thats holding the emitter, maybe. thats what you're testing with the image rotation above)

That didn't do much. It's still like the picture in the OP but if I turn at a certain angle look upwards it becomes this:

I was able to get to the point I'm at by following muffinmix's guide.
What I want is for when the ability is activated, a huge (horizontal) ring is made around the player. Is there any way where I can accomplish a horizontal ring by tying an emitter to a position rather than a player (if I can't do it attached to the player)?
Edit: It actually seems to glitch out when I'm looking at something that isn't a brick (sky, ground, ect).
Edit2: I actually got it to become horizontal, but it only does it if I'm looking at the sky or ground, or a brick reallly far away. I did rotation = eulerToMatrix("90 0 0"); on the HealerImage.
« Last Edit: June 27, 2016, 05:04:03 PM by Johnny Blockhead »

Is it mounted to the player (you)? That might explain the weird faults.

Could be that if you spawn a projectile to spawn an explosion at the players position it might work better. If you want it to sustain around the player you could use a tick which updates it until it stops and make the explosion lifetime low.

Is it mounted to the player (you)? That might explain the weird faults.

Could be that if you spawn a projectile to spawn an explosion at the players position it might work better. If you want it to sustain around the player you could use a tick which updates it until it stops and make the explosion lifetime low.
projectiles are a bad idea - images are the way to go if you don't want to have ghosting issues or issues where something hits the projectile and removes it.
they are mounted on him; no other way to get it to track him

johnny, how does it look like if you're looking at the ground nearby or whatever? try mounting on other slots, maybe. use %obj.mountImage(image, slot); insted of just the mountpoint parameter on the image. Take a look at hatmods to see how they mount images (except in this case you wont need to remove any player nodes)

Isn't the emote system based around projectiles? A very small lifetime followed by explodeOnDeath = true would do the trick. Then just make the explosion happen at the players location every half a second for the duration needed.

What if you set thetaMin and thetaMax to something like 0 (min) and 1 (max)?

What if you set thetaMin and thetaMax to something like 0 (min) and 1 (max)?
If I do that it becomes a tiny ball in front of, or below me.

projectiles are a bad idea - images are the way to go if you don't want to have ghosting issues or issues where something hits the projectile and removes it.
they are mounted on him; no other way to get it to track him

johnny, how does it look like if you're looking at the ground nearby or whatever? try mounting on other slots, maybe. use %obj.mountImage(image, slot); insted of just the mountpoint parameter on the image. Take a look at hatmods to see how they mount images (except in this case you wont need to remove any player nodes)
If I look far away, it becomes the perfect little horizontal ring I want it to be. If I look nearby, it becomes vertical, like the in-game picture in the OP. I'm pretty sure I don't need to mess around with mountpounts, here's the script I'm using:

function gameConnection::setEmitter(%client, %image, %timeout)
{
   if(!isObject(%client.player))
      return;
   %image = %image @ "Image";
   %client.player.mountImage(%image, 3);
   if(%timeout > 0)
      %client.player.schedule(%timeout, unmountImage, 3);
}


Isn't the emote system based around projectiles? A very small lifetime followed by explodeOnDeath = true would do the trick. Then just make the explosion happen at the players location every half a second for the duration needed.
I'll try this and get back to ya.


Yay! It works. Thanks for the help guys.
//Emote Workaround
datablock ExplosionData(HealingExplosion)
{
   lifeTimeMS = 5000;
   emitter[0] = HealerEmitter;
   soundProfile = AlarmSound;
};

datablock ProjectileData(HealingProjectile)
{
   explosion           = HealingExplosion;

   armingDelay         = 0;
   lifetime            = 10;
   explodeOnDeath      = true;

   uiName = "Healing Emote";
};

function servercmdHealing(%client)
{
   %p = new Projectile()
   {
      dataBlock = HealingProjectile;
      initialPosition = %client.player.getHackPosition();
      initialVelocity = "0 0 0";
      sourceObject = %player;
      client = %player.client;
      originPoint = %client.player.getHackPosition();
   };
   MissionCleanup.add(%p);   
}

obviously not overwatch

should have realized the emote/projectile system was the way to go. sorry for doubting your method jervan
you can probably skip the projectile part and just spawn explosion on the player, if there ends up being ghosting issues. or by using an emitternode object and moving it around, like i do in the laser finder addon
« Last Edit: June 27, 2016, 09:00:58 PM by Conan »

No worries, glad it's working :D
I think I remember reading a comment in an emote file badspot made about explosions not being spawn-able so that's why you have to spawn the projectiles. I don't know if he fixed it because it's not exactly intuitive.

It does remind me of overwatch too but that's honestly a good thing, best shooter art-design-wise since TF2!

obviously not overwatch

should have realized the emote/projectile system was the way to go. sorry for doubting your method jervan
you can probably skip the projectile part and just spawn explosion on the player, if there ends up being ghosting issues. or by using an emitternode object and moving it around, like i do in the laser finder addon
no ghosting issues should be experienced spawning explosions is probably the most ideal way of accomplishing this emitter ring
I'm 99% sure you cannot spawn explosions without a projectile

the only other way I would think of doing this is spawning an emitter node