Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 flyingtomohawk · Jun 20, 2015 at 02:37 AM · collisionrigidbodycollisionskinematic

seeking collision scenario solution : falling anvil vs. player

I'm creating a 2d platform, and have a scene with a platform with a boxcollider2d, a player gameobject with a non-kinematic rigidbody and 2d colliders, and a gameobject that works like thwomp from mario, its kinematic and has a box collider and moves using velocity in fixedupdate. Is there anyway when the thwomp comes down it does not clip in to the player or ground. I used a trigger event to set velocity to zero but it still doesn't work. Also when I set the thwomp to non kinematic, it works but I'm able to push it around with the player, which I don't want, I can set the weight really high but then the player gets pushed through the platform, or it bounces off the ground. So any idea's of how to do this with out clipping.

Comment
Add comment · Show 6
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 AlwaysSunny · Jun 20, 2015 at 02:37 AM 1
Share

I renamed your question to be more descriptive. What reaction do you want to achieve ins$$anonymous$$d? If neither clips into the other and neither can push the other, that's a paradoxical requirement.

You must have a plan for every conceivable outcome, so not just the thwomp vs. the player, but the thwomp vs. every other entity archetype. First thing that comes to $$anonymous$$d is that any entity in contact with the bottom edge of the thwomp while it's in motion should first be pushed until grounded, then die instantly. You could replace it with some kind of gibs or a smushed version of the entity. These gibs or smushed versions should not have collision dynamics with the thwomp, and should lie at a 2D depth "behind" the thwomp. What else did you have in $$anonymous$$d?

avatar image flyingtomohawk · Jun 20, 2015 at 07:02 PM 0
Share

Well ideally this is what I want to happen. There are 2 scenarios I can think of for the thwomp 1) is a wall/ground/moving platform, in this case i just want the thwomp to collide with the ground and then wait a second or two then return to its neutral position, 2) player or enemy, which is usually a box collider and circle colliders for head and legs, in this scenario i want the thwomp to hold the player down for a second and apply damage then return to a neutral position. I can achieve this by making the thwomp a non-kinematic rigidbody, but then the player is able to push the thwomp, I want the thwomp to be able to push the player, not the other way around. Sorry for not being more clear earlier.

avatar image AlwaysSunny · Jun 20, 2015 at 10:04 PM 1
Share

Okay, I have a better picture of the problem, I think. From your description, it does seem as though the thwomp object needs to be kinematic. A non-kinematic version might be quite interesting, and probably a lot easier to script for, but based on your stated requirements, it needs to be kinematic.

You can think of kinematic as being a toggle that says, "I will script all necessary responses to collision events for this object". Then it's your responsibility to actually do so, for every conceivable situation. When two thwomps meet, or one touches a moving platform, or a static platform, or a player, or any other object... It can get pretty messy if you're not careful.

You're also driving state logic based on these interactions. That's where the complexity can grow exponentially, depending on your requirements. For instance, it might respond one way to one scenario during its "attack" state, but respond another way to the same scenario during its "reset" state.

It's easiest to think of these Logic $$anonymous$$atrices as "who gets priority" in a hierarchical fashion. A thwomp-like object will probably supersede most others, it being a big bad unstoppable agent of destruction, and thus any other bodies interacting with it should give it the right-of-way.

If it collides with a player, the player will be pushed. It can detect that it's touching a player, and push the player until the player is mashed against a floor, wall, ceiling, etc. At that moment, the player might enter a special "stunned" state, denying the user permission to act. This stunned state might also be the thwomp's "rest" state, prior to returning home. In this specific circumstance, the player receives damage.

$$anonymous$$ixing pure physics, scripted kinematics, stateful behaviors, and other complex logic in a deter$$anonymous$$istic simulation is not an easy task. It requires exceptional care and planning, as well as a fairly comprehensive understanding of PhysX and Unity principles.

It may be worth considering alternatives that simplify your scenarios. Then again, if you have a strong enough command of the language and systems, you can create some highly modular and "foolproof" entities for your level designer to play with.

avatar image flyingtomohawk · Jun 21, 2015 at 03:27 AM 0
Share

I don't think I'll be able to do it just kinematic then. I experimented more and made the thwomp nonkinematic and then attached a child object bounds, that has a kinematic rigidbody and box collider. This seems to work like a charm, but only problem is I have a trigger on the thwomp that detects if it collides with the player, only problems is the thwomp is moving too fast, so when it hits the player it pushes it through the platform, before stopping. Is there anything I can do in physicsmanager2d to make it detect collisions faster or anything else.

avatar image AlwaysSunny · Jun 21, 2015 at 04:05 AM 1
Share

$$anonymous$$ind of. You can decrease the physics timestep for your project to have more physics calculations per second. This is rather expensive, and should be avoided if possible, unless the rest of your game requirements are light enough to support the expense. You can change a rigidbody's interpolation mode to change the way PhysX detects collisions with a particular body. See the rigidbody documentation to learn more about when to use each variant. Also this question seems to directly relate to this subject.

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

2 People are following this question.

avatar image avatar image

Related Questions

[SOLVED] Desactivate pushing forces between two objects 2 Answers

Rigidbody with Physics or Kinematic Rigidbody 1 Answer

Enemy rigidbody and bullet collisions 1 Answer

Child Rigid Body collision problem 2 Answers

Make isKinematic false when touching a Collider? 1 Answer


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