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 Pilessio · Jul 25, 2019 at 01:18 PM · animation2d-platformercollider2dobstacle

Moving BoxCollider2d with animation is not the right way?

Good morning, folks

I'm pretty new to Unity so certain patterns to make things are confusing me yet.

I'm creating a 2D game and in this case I want to create a simple "press" object that can press and damage player. You can watch video I've just uploaded here on Vimeo so you can fully understand my purpose.

So I've created some sprite (link here on Piskel, a animation (as you can see in video) and added a simple box collider that changes its offset during animation. As you can see in video, sprite and collider doesn't move properly synchronized and I think it's not a good idea to implements that object in that way, because collider should stay and it's the object transform that should move, but I can't figure why, so I'm asking to you which is in your opinion best workflow to implements this behaviuor.

Little corgi in video and me say "Thank you in advance"

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

2 Replies

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

Answer by RustyCrow · Jul 25, 2019 at 01:41 PM

Your video is set to private so can't watch it, BUT i think i get what you are trying to achieve.
So first i would recommend you check out the official tutorials for unity animations 2D so you understand the system better.

What you need to do is to create a Parent obj lets call it Thepress and then use this as your base game object.
Now you child(add to Thepress) the sprite(gameobject with sprite render), lastly you child a hitbox object(gameobject with 2d box collider).
From here you create a unity animation(i am assuming you know this) , add your sprite frames from your press animation and lastly you add your hitbox transform to the animation. What the transform will allow you to do is to animate the position of the hitbox, just sync it with your sprite frames and you should be done @Pilessio .

EDIT: @Pilessio After seeing your new public video i see the problem, The solution here would be to go to the curves tab in the animation window(lower left corner) and set all your Frams/keys to constant (Box select them all > right click > both tangent > constant). This will be more inline with with pixel frames, an instant shift per fram rather then the smooth motion.

Comment
Add comment · Show 4 · 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
avatar image Pilessio · Jul 26, 2019 at 08:02 AM 0
Share

Apologize for wasting your time, now I've just set video on Vimeo as public. Thank you for your answer

avatar image RustyCrow Pilessio · Jul 26, 2019 at 01:39 PM 0
Share

Np, i have updated my answer, check out the edit hopefully this will fix your issue.

avatar image Pilessio RustyCrow · Jul 29, 2019 at 10:15 AM 0
Share

Thank you so much!!!!

Show more comments
avatar image
0

Answer by I_Am_Err00r · Jul 25, 2019 at 01:39 PM

I tried watching the video, set to private, but I think I understand what you are experiencing; it sounds like you might even be using a 2D IK tool.


Unless you are moving the collider during the animation, what you are experiencing is the sprite is actually moving and the box collider and transform are staying in the same spot.


I work with an artist and I experience this all the time with them, but essentially it sounds like you are actually moving the sprite in it's local space when capturing keyframes.


The only things that should move in 2D animations are the IK points on the limbs and maybe bringing the top down for crouching (because crouching has a smaller collider) but other than that you want to move the sprite and capture the IK keyframes in the same position, even for things like jumping and sprinting (jumping and flying are the two my artist for some reason always sends with drafts having vertical local movement, and I have to remind them to stop doing that like literally every time).


If the animation keyframes show the sprite as changing local positions, it will capture that and make it appear like the box collider isn't following it, when it's the sprite not following the transform and moving around the local space.

Comment
Add comment · Show 1 · 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
avatar image Pilessio · Jul 26, 2019 at 08:01 AM 0
Share

Apologize for wasting your time, now I've just set video on Vimeo as public. Thank you for your answer

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

287 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 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 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

A problem regarding to player animation with checkpoint in 2D platformer 0 Answers

Jump animation will not play 1 Answer

2D animation diferent right and left 0 Answers

Animation Problem 1 Answer

Player Gets Stuck On TilemapCollider2D 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