Vector3 setting condition with the values
Hi everyone! For some reason I needed moderator approval for this question. Was told to post here directly. Here goes nothing :) So let's say I have a Rectangular rocket. There is a thruster particle system (ps) on each side. 4 total. And one thruster on the bottom. If the rocket tilts on the +X axis, I want the particles on that side to enable. If it tilts on the -X axis I want the particles on that side to enable. If I spin on the Y axis I'd like to enable the bottom thruster. With the code below I'm able to get the direction, angle, dot product. How can I use this info to set a condition to do the above scenario?
if (rocket tilts this direction){ do this }
Thank you for any help on this!
void PsUpdate(ParticleSystem myPs)
{
Vector3 initialPos = myPs.transform.position;
Vector3 changedPos = (myPs.transform.localPosition + ship.transform.position);
Vector3 target = changedPos - initialPos;
distance = target.magnitude;
Vector3 force = target / distance
Vector3 shipUp = myPs.trasnform.up;
angle = Mathf.Acos(Vector3.Dot(force, shipUp);
dotProd = (Vector3.Dot(force, shipUp));
Debug.Log($"Up direction: {shipUp}" + $"\tDotProd results: {dotProd}" + $"\t Angle: {angle}");
if (angle < 25)
{
for(int i=0; i< myPs.Length; i++)
{
myPs[i].Play();
}
}
else
{
myPs[i].Stop();
}
}
I normalized the target to get the direction. Just having a hard time understanding how I can tell direction from any of that in 3d space.
direction = (changedPos - initialPos).normalized;
if( direction == someValue ) { do this }
But how can I tell the direction? Reading page after page, but not really getting a grasp of this.