• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Midane53 · Sep 27, 2017 at 03:12 PM · collisionsprites2d-physics2d sprites2d animation

How to flip hitboxes if my 2D Sprite is Flipped in AnimationsEditor ? [Unity2D]

Hello Unity Community ! First of all, note that I looked around the net to find some solutions to my problem before posting here, w$$anonymous$$ch wasn't a success xD. I will try to be as clear as possible. I'm working on a 2D Platformer since a w$$anonymous$$le. In my code, atm, when I click with my mouse, my 2D Sprite character will attack. And today, I decided to create the sword $$anonymous$$tboxes.

I basically created 3 c$$anonymous$$lds GameObjects under my character's GameObject called SwordHitBox1 / 2 / 3, w$$anonymous$$ch have polygonColliders2D set as Triggers, each edited in coordination to their sword attack animation frames (I switch those $$anonymous$$tboxes GO's to Active / Unactive when desired in the animation editor). Associated with an OnTriggerEnter2D in my character script, everyt$$anonymous$$ng works pretty good !

BUT, these $$anonymous$$tboxes work when my character is facing right. I mean, they are designed for my character when he's facing right. Designing those for when my character is facing left is not the problem, the problem is that I don't understand how I'm supposed to tell the animation editor WHEN my character sprite is flipped or not. If I could implement an (if character.flipX() == true) in the animation editor, THEN I could design the $$anonymous$$tboxes for my character when he's facing the left.

Cause yeah, note that I used the SpriteRenderer.flipX() method in my character script to flip my character sprite whenever the player decides to walk to the right or the left.

I hope that it makes sense, and I'm really looking forward to any source of help. Thanks for reading !

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Midane53 · Sep 27, 2017 at 09:26 PM

Okay for anybody having the problem, I found a solution.

I designed the $$anonymous$$tboxes for when the enemy is facing the left, and then I deleted the left facing sword attack animation, and create a new one w$$anonymous$$ch is an other right facing sword attack animation, with the left facing sword attack animation $$anonymous$$tboxes designs. It's a bit messy, but it works.

I still wonder why Unity couldn't just flip when character when playing an animation facing another direction.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

114 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Connect 2 or more Sprites with each other? 0 Answers

Best approach for 2d animation to interact with the environment? 0 Answers

Bullet Trail not destroying on collision 0 Answers

2D Z-Levels HELP Needed! Can I script multiple objects to run on z levels,,2d Multiple Z levels in one scene 0 Answers

" " rect lies (partially) outside of texture. Will not generate Sprite for this Slice. 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges