TGB 1.7.x: Particle Mount+Flip+Rotation Issue
by Brian Wilson · in Torque Game Builder · 07/15/2008 (10:53 pm) · 4 replies
I've bumped into a brick wall on this on. I've got a player sprite, with mounted rotating engines, with a thruster emitters mounted onto those. Everthing works fine with rotation until I set the player X flip. The engines still flip ok, but the emitter does not.
My flip code works like this:
Here's a table of the action.

The player is set up in the builder, if that makes a difference. The engines are set to "Owned by Parrent", and "Inherit Attributes". The engines rotate and flip properly. As far as the particle emitters go, the only mount setting that appears to have an effect is "Track Rotation". "Owned by Parrent" and "Inherit Attributes" do not seem to effect the rotation/flip behavior at all.
Any ideas?
My flip code works like this:
if($thePlayer.getLinearVelocityX()<0) $thePlayer.setFlipX(1); else $thePlayer.setFlipX(0);
Here's a table of the action.

The player is set up in the builder, if that makes a difference. The engines are set to "Owned by Parrent", and "Inherit Attributes". The engines rotate and flip properly. As far as the particle emitters go, the only mount setting that appears to have an effect is "Track Rotation". "Owned by Parrent" and "Inherit Attributes" do not seem to effect the rotation/flip behavior at all.
Any ideas?
#2
For Flip active and Press Up:
%emitterL = Leftjet.getEmitterObject(Leftjet);
%emitterL.selectGraph(emissionangle_base);
%emitterL.setDataKeyValue(0, 180.000);
For Flip active and Press Up/Left:
%emitterL = Leftjet.getEmitterObject(Leftjet);
%emitterL.selectGraph(emissionangle_base);
%emitterL.setDataKeyValue(0, 135.000);
For Flip active and Press Left:
%emitterL = Leftjet.getEmitterObject(Leftjet);
%emitterL.selectGraph(emissionangle_base);
%emitterL.setDataKeyValue(0, 90.000);
Think that should work although you'd need the above for both jets, the jet themselves are named Leftjet in the level but you should call whatever youve called them.
I'd have a function call inside your flip code, and then another function doing exactly the same to reset them too.
Hope thats clear! :D
08/01/2008 (5:41 am)
I had the same problem before, the emission angle won't flip. The only way to do it is to get the particle effect and assign it to a temporary variable and then access the correct graph and change the values as below:For Flip active and Press Up:
%emitterL = Leftjet.getEmitterObject(Leftjet);
%emitterL.selectGraph(emissionangle_base);
%emitterL.setDataKeyValue(0, 180.000);
For Flip active and Press Up/Left:
%emitterL = Leftjet.getEmitterObject(Leftjet);
%emitterL.selectGraph(emissionangle_base);
%emitterL.setDataKeyValue(0, 135.000);
For Flip active and Press Left:
%emitterL = Leftjet.getEmitterObject(Leftjet);
%emitterL.selectGraph(emissionangle_base);
%emitterL.setDataKeyValue(0, 90.000);
Think that should work although you'd need the above for both jets, the jet themselves are named Leftjet in the level but you should call whatever youve called them.
I'd have a function call inside your flip code, and then another function doing exactly the same to reset them too.
Hope thats clear! :D
#3
Thanks again for the response.
10/29/2008 (4:05 am)
Sorry, I shelved the project for a couple of months and am firing it back up this week. I'll let you know how these suggestions work out.Thanks again for the response.
#4
Your solution worked like a charm. Thanks again.
Here's my code, as sloppy as it is...
11/30/2008 (1:52 pm)
@AdamYour solution worked like a charm. Thanks again.
Here's my code, as sloppy as it is...
function engineClass::OnLevelLoaded(%this, %scenegraph)
{
$engineFront = engineFront;
$engineBack = engineBack;
}
function engineThrusterClass::OnLevelLoaded(%this, %scenegraph)
{
$engineFrontThruster = engineFrontThruster;
$engineBackThruster = engineBackThruster;
}
// engineRotation is called at the end of my functions called for movement to update the engine rotation
function engineRotation()
{
%emitterFront = $engineFrontThruster.getEmitterObject($engineFrontThruster);
%emitterBack = $engineBackThruster.getEmitterObject($engineBackThruster);
if($moveRight||$moveLeft||$moveDown||$moveUp)
{
if($moveRight&&!$moveLeft&&!$moveUp&&!$moveDown)
$engineRotation = 0;
else if($moveRight&&!$moveLeft&&!$moveUp&&$moveDown)
$engineRotation = 45;
else if(!$moveRight&&!$moveLeft&&!$moveUp&&$moveDown)
$engineRotation = 90;
else if(!$moveRight&&$moveLeft&&!$moveUp&&$moveDown)
$engineRotation = 135;
else if(!$moveRight&&$moveLeft&&!$moveUp&&!$moveDown)
$engineRotation = 180;
else if(!$moveRight&&$moveLeft&&$moveUp&&!$moveDown)
$engineRotation = 225;
else if(!$moveRight&&!$moveLeft&&$moveUp&&!$moveDown)
$engineRotation = 270;
else if($moveRight&&!$moveLeft&&$moveUp&&!$moveDown)
$engineRotation = 315;
$engineFrontThruster.setVisible(true);
$engineBackThruster.setVisible(true);
}
else
{
$engineFrontThruster.setVisible(false);
$engineBackThruster.setVisible(false);
}
%emitterFront.selectGraph(emissionangle_base);
%emitterBack.selectGraph(emissionangle_base);
if($thePlayer.getFlip())
%mod = 180;
else
%mod = 0;
$thrusterRotation = $engineRotation-90;
%emitterFront.setDataKeyValue(0,$thrusterRotation);
%emitterBack.setDataKeyValue(0,$thrusterRotation);
$engineRotation += %mod;
$engineBack.setRotation($engineRotation);
$engineFront.setRotation($engineRotation);
schedule(50,0,"engineRotationEngine");
}
Torque Owner WesTT