Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

  • 0
Sign in to follow this  
V3ndetta

Vector 3 flipping X scale changes sprite movement direction

Question

Hello, I have made two scripts, one that controls the player's movement in the world, and one that takes care of it's animations. In order for me to be able to show the player moving to the right side, I needed to flip the animation direction, which I did by flipping it's X scale(-1) . The problem is, that if I do that, for some reason even if I want to move to the right, my player moves to the left, being forced because of the flipped X scale as I saw. After giving it positive value, it didn't happen anymore. Is there any other method that flips the sprite, while not interfering my movement script?

 

My movement Script:

 

Please login or register to see this code.

 

My Animator controller Script:

 

Please login or register to see this code.

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 1

Remember to check google and scripting reference before asking here. Here I found what you need.

Please login or register to see this link.

 

 

  • Like 1

Share this post


Link to post
Share on other sites

  • 0

Thanks, I did check and come across that but I got some issues with it, until I saw that I have to assign it a boolean value too.

Share this post


Link to post
Share on other sites
  • 0

Since Unity 5.3, there is built-in "Flip" support. Just check whether you want to flip by X, Y, or both.

In code, you could just assign true/false to SpriteRenderer.flipX and SpriteRenderer.flipY - easy way ++

Please login or register to see this link.

Please login or register to see this link.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...