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 am0314 · Apr 15, 2015 at 07:10 PM · c#collisioncharactercharactercontroller

How not to penetrate the walls?

I use the following code to move my character

 transform.position + = new Vector3 (x * Time.deltaTime, 0, y * Time.deltaTime);

However, if the crash barrier, will penetrate and bounce I studied 'Standard Assets Example Project' but no harvest

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

3 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Olgo · Apr 15, 2015 at 07:36 PM

by editing the position of your character, that's all you're doing, changing his position without being cognizant of collisions.

Add a character controller and use the .Move() function to control your character. This will check for collisions and stop accordingly.

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 am0314 · Apr 16, 2015 at 06:39 AM 0
Share

I tried this method, he can really move! But in addition to '.move', penetrate anything Given rigid body and gravity, will penetrate the terrain

avatar image am0314 · Apr 19, 2015 at 11:06 AM 0
Share

I try to use the $$anonymous$$ove gravity, it appears that a temporary solution to the problem

avatar image
0

Answer by Tim Jansen · Apr 15, 2015 at 07:43 PM

I don't know what your scene looks like, but a common problem is that the character is moving so fast, that the character moves past the wall in between two physics updates, so the character has past the wall before the next update. If that is the problem, making the wall (or otherwise the collider) thicker or limiting the speed of your character should solve the problem.

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 am0314 · Apr 16, 2015 at 06:46 AM 0
Share

I do not know what to do to limiting But if the scene is always thick walls, it seems not nice

avatar image Tim Jansen · Apr 16, 2015 at 10:15 AM 0
Share

It must pretty fast for this to be a problem, so if the character is moving relatively slow, then this is not the problem. Have you checked that not only the character has an collider, but the wall as well and that "Is trigger" is unchecked on both of them?

avatar image
0

Answer by VoidScreamer · Apr 15, 2015 at 09:22 PM

a common cause is that "Drag" property on your RigidBody is 0. so it bounces and slides indefinitely. try 1 or 2. since you don't use AddForce for moving you Object, it doesn't affect physics. with drag set to 1, it will stay still after a little Bounce.

Note : you need a non-kinematic rigidbody and a non-trigger Collider to avoid penetration.

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 am0314 · Apr 16, 2015 at 06:50 AM 0
Share

I tried using AddForce or other things But more unpredictable physical phenomena will happen, I do not know how to solve For example Danfei or impact

avatar image VoidScreamer · Apr 16, 2015 at 08:47 AM 0
Share

I prefer translate over addforce for many movement purposes. anyway, the drag should be set about 1 for translate. note that if you set it 1 and use addforce, the object will not move due to very high drag.(needs about 50000000 force for just 50 mass units). so set it carefully

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

OnCollisionEnter not working 1 Answer

How can I limit the rotation on the Y axis so the player cant spin the camera 360 in an FPS game? 0 Answers

Two Basic Physic Questions (Gravity and Jumping) 1 Answer

How to trigger different animations depending on where a gameobject collides? 1 Answer

[C#] Jump on slopes 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