Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • 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, which wasn't a success xD. I will try to be as clear as possible. I'm working on a 2D Platformer since a while. In my code, atm, when I click with my mouse, my 2D Sprite character will attack. And today, I decided to create the sword hitboxes.

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

BUT, these hitboxes 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 hitboxes 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 hitboxes for when the enemy is facing the left, and then I deleted the left facing sword attack animation, and create a new one which is an other right facing sword attack animation, with the left facing sword attack animation hitboxes 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.

Follow this Question

Answers Answers and Comments

115 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 avatar image

Related Questions

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

Per-Sorting Layer Collision 1 Answer

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

Connect 2 or more Sprites with each other? 0 Answers

Best approach for 2d animation to interact with the environment? 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