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 tertle · Feb 21, 2011 at 12:09 AM · collisionphysicsrigidbodycharactercontroller

Prevent rigidbody being affected by character controller

There are potentially 3 ways I've thought of which I've put in bold, that if I figure out just one of them, then my stuff will work.

I'm trying to write a script so that my character can be crushed by objects. I'm using a CharacterController for what I'll call the 'controller' and the objects crushing him are rigidbodies which I'll call the 'crusher'.

The crusher is currently using a non-kinematic rigidbody, gravity disabled and constraints set to all. I can detect being crushed perfectly fine, the problem is when my controller, say jumps, it pushes the crusher away making it fly off. How can I stop a character controller from moving the rigidbody?

I've tried setting rigidbody.velocity = Vector3.zero; every FixedUpdate. This stops the crusher flying away but you can still notice resistance.

Now if I make crusher a kinematic, it works fine, but I lose the ability to use OnCollisionEnter() and therefore the way I'm detecting the player being crushed. Is there anyway to detect a collision between a kinematic and a character controller without using OnControllerColliderHit?

Would attaching a rigidbody to my controller give me back OnCollisionEnter?

Finally I thought about using a trigger on the crusher and using OnTriggerEnter, but if I jump I just pass through the crusher. Is there anyway to prevent a collider passing through a trigger? I tried attaching a trigger to another rigidbody as a child but I still passed through it most of the time. Would separating them and position them at same place through a script work?

Cheers for advice.

-edit-

Got a video of current issue.

http://bovinelabs.com/crush/crush/

This is using a rigidbody kinematic and a separate trigger

The crusher moves on FixedUpdate() using

rigidbody.MovePosition(rigidbody.position + _direction*Speed*Time.deltaTime);

CharacterController is a heavily modified version of the FPSwalker to allow stuff like wall jumping, but I do not believe any changes would affect this.

Notice it only really does it when it's going down, and I'm moving up

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 Brian-Kehrer · Feb 21, 2011 at 12:18 AM

Use a trigger to detect crush, and then have a kinematic rigidbody collider to prevent your character controller passing through your object. In short, two separate objects (preferably set to ignore each other).

If you make the trigger a bit smaller than the collider, you can have some 'safety' region, so you can't jump into the crush trigger.

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 tertle · Feb 21, 2011 at 07:46 AM 0
Share

O$$anonymous$$ tried this again. I still get same issue I had last time I did that. About 30% of the time I still jump through the platform. Only way I can seem to fix this is if I crank up skin width to around 50% of the radius, but this causes hovering. Also OnTriggerEnter doesn't fire off unless my controller is also moving (falls asleep?) I'll record a video of what's happening.

avatar image
0

Answer by Joshua · Feb 21, 2011 at 01:31 AM

To stop your character from pushing the crushers away you could always make the weight of them huge compared to the characters str.

Comment
Add comment · Show 2 · 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 tertle · Feb 21, 2011 at 07:46 AM 0
Share

Weight on 100,000. Doesn't seem to change anything when you use a constant move on a rigidbody from a character controller.

avatar image Joshua · Feb 21, 2011 at 11:46 AM 0
Share

That is really strange. But, do you want your character to keep moving after he is crushed? You could make the crusher a trigger and implement a line in your charactermovement script that disables it when crushed.

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

No one has followed this question yet.

Related Questions

Is there a rigidbody character controller 3rd person that can handel stairs (steps)? 1 Answer

Can't use Rigidbody or Character Controller 0 Answers

Is it ok to move objects with CharacterControllers not through their CharacterController and without adding a kinematic Rigidbody? 1 Answer

Physics AddForce reduced when 3 objects are colliding 1 Answer

Character Controller meets Rigidbody 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