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 Jon7e · Jul 09, 2017 at 02:30 PM · collisioniskinematic

my character is falling through the floor

I want to have a character made out of cubes and affected by gravity to be destroyed per cube when I drop a ball on it with a script to destroy everything it touches. I want to let the character move too.

I have a character made out of different cubes parented to an empty gameobject with a rigidbody. all the cubes have a box collider. I have given all the cubes a kinematic rigidbody which let the cubes be destroyed seperately if I toggle off the gravity of the empty game object. But when I toggle it on my character falls through the floor.

Is there a way to not let the character fall through the floor?

Thanks in advance.

Comment
Add comment · Show 1
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 SeaLeviathan · Jul 09, 2017 at 02:40 PM 0
Share

Just really quick, the reason he is falling through the floor is the kinematics. I will give you an answer with proper documentation and ways to understand or fix this problem.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by SeaLeviathan · Jul 09, 2017 at 03:02 PM

Ok, I did some testing and I think I found a way to answer your question. When force is applied to a kinematic object, like a player falling due to gravity, the kinematic object ( to put it simply) can be interacted with, but does not interact with the world. That might be confusing, here's a link to the manual : https://docs.unity3d.com/Manual/class-Rigidbody.html You will just want to look at isKinematic. Basically it's used for interacting with objects with collision, but without moving them (Like the doc says, moving platforms)

This answers page has a pretty good explanation of kinematic bodies too: http://answers.unity3d.com/questions/580710/iskinematic-rigidbody-collisions.html (Look for the answer in like 20pt font)

You still have the question about making your character NOT fall through the floor, and I also understand where your need for kinematic rigidbody comes from, so I will suggest one of two things.

  1. Try to raycast collisions (This is kind of difficult and sometimes not too reliable)

  2. Make a gameobject for the feet of your player, position it correctly and then take off the mesh renderer and set its box collider to isTrigger. Then you can make a basic script for detecting collisions with that. ( I have a script like this, so if you can't figure that out I can help you there too)

Maybe this helped or it was just confusing, either way hope you can figure it out!

Comment
Add comment · Show 12 · 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 Jon7e · Jul 09, 2017 at 03:49 PM 0
Share

I tried to do the second one but I am stuck at the script part. I made a script using OnCollisionEnter and OnCollisionExit to check if the box hits the ground or not. I checked if it worked with a Debug.Log message but I did not recieve a message when the boxes hit the ground. I am also thinking of letting the character stop by activating the Is $$anonymous$$inamatic of the empty gameobject but i don't know if that is going to have consequences for if I want to move it.

avatar image SeaLeviathan Jon7e · Jul 10, 2017 at 04:57 PM 0
Share

Like I said I can help you with the script part for 2.

This is what I have, ill paste the important parts and explain through it. You are going to want to have the feet object parented to the player object, so it stays with you.

Script called grounding:

     public bool isGrounded;
 
     private void Update()
     {
 
     }
     
         private void OnTriggerStay(Collider other)
         {
             isGrounded = true;
 
 
         }
         private void OnTriggerExit(Collider other)
         {
             isGrounded = false;
         }
     

This part is for just setting a public boolean from true to false, depending. You said you tried OnCollisionEnter and Exit, but if you set this feet gameobject to a trigger as I had suggested, there would be no collisions, so this is where OnTrigger comes into play. A section of my fpsman script:

     private void jump()
     {
         grounding feet = GameObject.FindGameObjectWithTag("Feet").GetComponent<grounding>();
         if(Input.Get$$anonymous$$ey("space") && feet.isGrounded)
         {
             rb.AddForce(0, jumpSpeed, 0, Force$$anonymous$$ode.Force );
         }

this first part of the function is a reference to the first script, called grounding. to get a reference, you call the class of the script you want to get a variable from (In this case "grounding"), give it a name just like a variable, (I called it feet) and set it equal to whats shown above. The tag is something you set up in the unity editor, it's a really useful way of communicating between objects and groups of objects. In this case, on the bottom of my player, I made a cube that fit on my characters feet, and tagged it "feet" accordingly. The last part is just GetComponent. So in our case, we want to access the "grounding" class as to get our isGrounded variable. The addforce inside of the if statement is just another way of moving an object, you can use whatever method you like. (in my case, I used a public variable I made called jumpspeed in the addforce function).

Once you have done all of this, you are going to want to attach the grounding script to the feet object.

Hope this helped! $$anonymous$$essage again if you need more help still!

avatar image Jon7e SeaLeviathan · Jul 10, 2017 at 05:34 PM 0
Share

For some reason my character is still falling through the floor.

Show more comments
avatar image
0

Answer by botboi360 · Nov 27, 2020 at 04:38 PM

Just add a capsule collider and make sure that the ground has a box collider

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

105 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

Related Questions

Detect collision and prevent intersection 1 Answer

How to get collision point when using onTriggerEnter 5 Answers

rigidbody - kinematic performance 0 Answers

how to check for collison with a navmeshagent 0 Answers

Detect Contact between Kinematic and Non-kinematic bodies 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