P
P
Pavel Arutyunov2022-02-06 19:17:18
Mobile development
Pavel Arutyunov, 2022-02-06 19:17:18

The Flip function does not work, what should I do?

Hello!
When adding animation to the player, the Flip function stops working, but when the animator is turned off, the function works properly. Please tell me what is the problem.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mimocodil, 2022-02-07
@GLaWA_RaKoB

Make one root object, which will have all the main stuffing (movement + rigid body + colliders). Make objects with graphics child.
When rotating the character, do not flip, but rotate along the Y axis of the root of the object. Something like this (x is the input from the "Horizontal" axis):

if (x != 0)
    transform.eulerAngles = new Vector3(transform.eulerAngles.x, x > 0 ? 0 : 180, transform.eulerAngles.z);
// если оси X/Z без вращения, то можно так:
if (x != 0)
    transform.eulerAngles = new Vector3(0, x > 0 ? 0 : 180, 0);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question