Instead of:
float dotProduct = Vector3.Dot(dir, transform.right);
int front = 0;
int back = 0;
if (dotProduct > 0)
{
// right
front = 1;
back = -1;
}
else if (dotProduct < 0)
{
// left
front = -1;
back = 1;
}
Rotate(front, back, angle);
Having something like
float dotProduct = Vector3.Dot(dir, transform.right);
int front = Mathf.Abs(dotProduct) ...;
int back = Mathf.Abs(dotProduct) ...;
Rotate(front, back, angle);
Errh, I know int front = Mathf.Abs(dotProduct) ...;
wont give me either 1 or -1, but I think you understand what I'm thinking, instead of using if's, I'd be "funneling" through an equation that would give me either 1 or -1.
Aucun commentaire:
Enregistrer un commentaire