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 Ossyahn · Nov 27, 2014 at 08:22 PM · collisionphysicsrigidbody

Collision not working properly in a Fixed Joint

I have a 2.5D platformer, where the character puts objects upon his head (objects as big as him) and can move through the scene with them on top of it.

To accomplish that, I put the object (a cube) on its head modifying the cube's rigidbody.position and I create a fixed joint on the character's head with the cube as Connected Body, with enable collision as true (although true o false seems to make no difference with the problem). This is the code:

     fixedJoint = anchorPoint.gameObject.AddComponent<FixedJoint> ();
     fixedJoint.connectedBody = item;
     item.mass = itemMass;
     item.constraints = RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ;

Where anchorPoint is an empty object, child of the character, with the correct position where the fixedJoint should be and item is the rigidbody of the cube.

And this is the jumping function:

 void Jump(){
 
         if (isGrounded && !isDown) {
             rigidbody.AddForce(Vector3.up * minJumpForce , ForceMode.Impulse);
             isJumping = true;
             pointOfOrigin = groundDetector.position;
         }
 
         if(groundDetector.position.y - pointOfOrigin.y > maxJump){
             isJumping = false;
         }
 
         if (isJumping) {
             rigidbody.AddForce(Vector3.up * jumpIncrement , ForceMode.Force);
         }    
     }

Which is executed every FixedUpdate while the jump button is pressed.

The problem is that the cube no longer collides with platforms above the character's head. If the character is under a platform and jumps, the cube on his head passes through the collider of the platform from below and remains "inside" the platform until the head hits the collider correctly. Then the character stops and falls with the cube still attached.

Even worst, if the platform height is thin enough to let some part of the cube to reach the other side of the platform collider, the cube teleports to the other side, but can't go down because now the collider does work, stretching somehow the fixed joint. If the character then moves to the left or right, the cube follows him sliding through the platform, and when reaches the end, without the collider in-between, it jumps to his head again, all of it without breaking the fixed joint (with break force set to infinity).

If I make the cube child of the character it also makes no difference. The colliders doesn't "concatenate", the platform stopping the cube from passing through it and the cube stopping the character from reaching the platform, which is what should happen.

The character is moving using the rigidbody (rigidbody.moveposition()) and jumping adding up force to it, so I'm not messing whith the transform at all. I've also tryed setting the collision detection to constant dynamic for the cube and contant for the platform in case that the problem was that the cube was hiting too fast, but no difference, and also the character without the cube is colliding perfectly and is moving at even more speed (because has't to lift the cube mass too in addition of its own).

I'm not sure what I'm doing wrong.

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

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

How may I observe expected physical interactions while using Rigidbody.MoveRotation()? 1 Answer

Collision interpenetration and object getting stuck 1 Answer

How do I "remove/disable" collision? 3 Answers

Camera and mesh not colliding 1 Answer

Disable physics reaction 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