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
1
Question by JustinTheSwift · Dec 16, 2018 at 07:34 PM · rigidbodycharactercontrollercharacter controllerrigidbody physics

Best Strategy to interact with rigidbody

I am experimenting with building a game which has two main requirements:

  1. A playable character which moves as with a character controller (quick acceleration and sudden stops, quick turns, no gravity effect, etc.)

  2. The ability to interact with object using realistic physics that make the most sense with a rigid body (for example, my character runs into a box and pushes it off of a shelf onto an enemy below).

So my question is: what is the best strategy for building a game with the best of both worlds? If I want to use a character controller on my character, and a rigid body on my box, how can I make a man hit the box and knock it off? It appears that the rigid body and CC just don't work together - so what combination DOES work?

And also, I'm aware that the simple task of pushing a box off of a ledge would be fairly easy if I coded it by hand, but I'm looking for realistic physics and also interaction with a wide variety of environmental items, so coming up with a way to hard-code transforms for everything in the game without physics just won't cut it.

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
2
Best Answer

Answer by JustinTheSwift · Dec 16, 2018 at 08:00 PM

I found the solution to my own problem.

https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnControllerColliderHit.html

That page shows how to use the OnControllerCollider method of the CharacterController. The method detects a hit against a rigid body and defines the direction in which the box ought to be pushed.

Vega's answer (while appreciated) is not correct.

Comment
Add comment · Show 3 · 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 Vega4Life · Dec 16, 2018 at 08:14 PM 0
Share

How is it not correct exactly?

avatar image JustinTheSwift Vega4Life · Dec 16, 2018 at 09:07 PM 0
Share

Because, if I understand you correctly, you're saying that my character controller should automatically interact with a rigid body, but it doesn't. You seemed to say that adding a rigid body to a box would solve the problem, but my question explicitly stated that I had already done so to no avail. I had to implement the method mentioned above to describe the interaction between the controller and the rigid body to make the box move.

avatar image Vega4Life JustinTheSwift · Dec 16, 2018 at 09:22 PM 0
Share

If you are moving the character controller via move, then you are correct. I would recommend moving it via transform.position. Having to deal with your own forces is absurd for what you are wanting to do. (I made the assumption you were moving it with transform.position - which will indeed move other objects).

avatar image
0

Answer by BuzzyRoboYT · Feb 02 at 01:54 PM

This helped me thanks!

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

142 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

Related Questions

My player is stuck on left and right side(Endless Runner) 0 Answers

How does the premade FPSController handle character physics? 1 Answer

Physics goes crazy when rigidbody collides with moving character controller 0 Answers

Making a Character Controller push another Character Controller 3 Answers

FPS Character Controller with the push DOWN rigidbodies ability 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