Sprite Flipping && Rigidbody Movement Problems

Hello, i make it short… i’ve got 2 problems

Problem 1:
My Character is Flipping right but i cant see the Sprite from the other side… what should i do?
2098230--137315--bobbing.PNG 2098230--137316--flipping.PNG
Here is my code:

void Flip ()
    {
        Vector3 flipScale;

        flipScale = rb.transform.localScale;
        flipScale.x *= -1;

        rb.transform.localScale = flipScale;
        facingRight = !facingRight;
    }

Problem 2:
I move my Character with the Rigidbody velocity but when i move the character is bobbing little bit around, i’ve tried to solve the problem with FixedUpdate() but it dosen’t change…
2098230--137319--bobbing - Kopie.PNG
Here is my code:

void Start ()
    {
        source = GetComponent<AudioSource>();
        rb = GetComponent<Rigidbody>();
    }

    void FixedUpdate ()
    {
        Movement();
    }

    void Movement ()
    {
        //Turn Right
        if (Input.GetKey(turnRight))
        {
            rb.velocity = new Vector3(walkSpeed, rb.velocity.y, rb.velocity.z);

            if (!isPlayingSound)
                StartCoroutine(walkStepsAudio());

            if (!facingRight)
                Flip();
        }
}

Problem 1 can be solved by turning culling off in the sprite shader. If you’re using the default sprite shader you’ll need to make a copy of the shader and in the SubShader section underneath Tags and LOD you’ll find the section where you can put “Cull Off” and it will turn off backface culling for the shader, making it so you can flip the sprite around and still see it from behind. You can find the source code for the standard shaders in the archives here: http://unity3d.com/get-unity/download/archive

1 Like