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 hibbzy · Jul 30, 2018 at 01:19 AM · collisionrigidbodycollisions

collisions not working

my scene contains 2 boxes and a floor.

my character can stand on the floor and boxes but if i run at the side of the boxes the character goes through.

im not sure what im doing wrong.

 private void move2()
 {

    // Debug.Log("move2 called");
     if (Input.GetKey(KeyCode.W))
         rb.MovePosition(transform.position + transform.forward * speed * Time.deltaTime);
        
     if (Input.GetKey(KeyCode.S))
         rb.MovePosition(transform.position - transform.forward * speed * Time.deltaTime);
    


     if (Input.GetKey(KeyCode.A))
         rb.MovePosition(transform.position - transform.right * speed * Time.deltaTime);
    
     if (Input.GetKey(KeyCode.D))
         rb.MovePosition(transform.position + transform.right * speed * Time.deltaTime);
     

     if (Input.GetKeyDown("space"))
         jump();
 },i don't understand why my player doesn't fall through the floor but can run through walls.

my scene contains a floor and 2 boxes, i can stand on the boxes and the floor but if i try walking into the boxes my character goes strait through.

i was originally using transform.translate but a quick google search made me try rb.moveposition instead it works the same except i still have the same problem. its obviously colliding because it wont fall through the floor but i have no idea why the walls dont stop it.

private void move2() {

    // Debug.Log("move2 called");
     if (Input.GetKey(KeyCode.W))
         rb.MovePosition(transform.position + transform.forward * speed * Time.deltaTime);
        
     if (Input.GetKey(KeyCode.S))
         rb.MovePosition(transform.position - transform.forward * speed * Time.deltaTime);
    


     if (Input.GetKey(KeyCode.A))
         rb.MovePosition(transform.position - transform.right * speed * Time.deltaTime);
    
     if (Input.GetKey(KeyCode.D))
         rb.MovePosition(transform.position + transform.right * speed * Time.deltaTime);
     

     if (Input.GetKeyDown("space"))
         jump();

what am i doing wrong

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 Harinezumi · Jul 30, 2018 at 07:18 AM 0
Share

The problem is probably how the colliders and the rigidbody is set up. The questions might be tedious and too basic, but there are many options, so please bear with me. The questions are:
- does the box have a collider? (if not, add one)
- is the trigger checkbox on the box's collider unchecked? (if no, uncheck it)
- does your character have a collider? (if not, add one, but not a $$anonymous$$eshCollider)
- What type? ($$anonymous$$eshColliders tend to detect collisions more poorly)
- is your character's rigidbody set to kinematic? (if yes, you may want to uncheck it, but it depends on what you want)
- does your character's rigidbody use gravity? (if not, then that's why you can "stand" on the box)
- what are your character's interpolate and collision detection settings?
- how much is the speed value in the above code? If it is very high, you will need to set collision detection to continuous dynamic

Additionally, you might want to look into the CharacterController component: this handles character movement and collisions itself, and does not need (and should not have) a rigidbody.
Finally, don't set transform.position if you have a rigidbody on the game object, because it causes performance issues with the physics engine. If you want to teleport your character set position with rigidbody.position - this will ignore colliders when moving (unlike $$anonymous$$ovePosition(), which checks for collisions, although sometimes poorly).

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by wsimm101 · Jul 30, 2018 at 07:02 AM

I'm not pro but apparently sometimes the update function goes quicker and it goes through the thing. Maybe make the collier bigger? or add a raycast? or try layer or tag?

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

162 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 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

seeking collision scenario solution : falling anvil vs. player 0 Answers

Child collision detection?? help please 1 Answer

Transform collider not detecting collision on rigidbody collider 2 Answers

Collision detection from specific directions using rigid body character? 0 Answers

rigid bodies passing through one another. 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