A
A
Artemy2020-04-22 19:08:34
Algorithms
Artemy, 2020-04-22 19:08:34

How to rotate a character without using a conditional operator?

Is it possible to rotate a sprite in the direction of movement not through a conditional operator, but through mathematics?

I thought of the option below, but it doesn't work.

transform.eulerAngles = new Vector3(0, (transform.rotation.y + 180f) % 360f, 0);


PS Am I right that using math is cheaper than using operators? =.=

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2020-04-22
@Artemonim

Am I right that using math is cheaper than using operators? =.=

A very controversial point, but conditional operators are extremely cheap.
If we're not talking about shaders.
And premature optimization is an extreme evil.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question