Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 JNguyen · May 04, 2011 at 04:02 AM · characterwalkthroughsolid

How to make a solid object so that character cannot walk through

Hi,

I am new to Unity. I am having a problem with a solid object. I wonder how to make a solid object so that the character cannot walk through it. I even try Mesh Colider but it's seem not working, my character still walk through it.

Thanks

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 cameronisscared · Sep 10, 2013 at 10:57 PM 0
Share

If the separate pieces were not grouped, you have to add a mesh collider to all of the pieces. I had the same problem when I was making a desk, but I fixed it and now I'm fine.

5 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Alec-Slayden · May 04, 2011 at 04:47 AM

Hi JNguyen

Your solid object and your character must both have colliders, but the types of colliders must be a certain mixture. For example, two cube colliders will ignore each other unless one has a rigidbody.

There are very specific ways colliders will work together. At the bottom of each page in the manual dealing with a collider, there is a collision matrix to help you.

Also make sure you do not have "is Trigger" selected for your colliders. This is a setting that is for trigger detection only, without any physical collision.

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 BluEye · Sep 12, 2012 at 12:34 AM 0
Share

Is there a way to have isTrigger checked and still have the physical solidness of an object? @Alec Slayden

avatar image RecyclingBen BluEye · Mar 22, 2017 at 11:27 AM 0
Share

there is a function called OnCollisionEnter(){}

avatar image
0

Answer by wmadwand · Nov 04, 2014 at 05:24 PM

Primarily your Character must be solid. For that do this: select your Character in the Hierarchy -> go to the Inspector -> select and expand Capsule Collider -> uncheck "Is Trigger".

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
avatar image
0

Answer by GaryTheBard · Feb 06, 2017 at 01:05 PM

@BluEye - Yes you can technically have IsTrigger checked and still have the physical solidness of an object. I needed to solve this same issue, where I wanted the graphic of a platform to change when the player collided with it. Unfortunately, I was able to get the graphic to change, but then the character would just pass through the new platform. The way I solved it was setting IsTrigger to false within the OnTriggerEnter. If you need the trigger to occur every time that the player collides, you can set IsTrigger back to true in the OnTriggerExit portion.

         this.gameObject.GetComponent<BoxCollider2D>().isTrigger = false;
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
avatar image
0

Answer by umair_hassan · Mar 22, 2017 at 11:10 AM

alt text If you are transforming your character, no collider will stop him from passing through unless you check in OnCollisionEnter() function and stop him if he collides to the hurdle.

e.g:

  1. float speed = 5;

  2. void Update(){

  3. transform.position = transform.forward 20 speed;

  4. }

  5. void OnCollisionEnter(Collision hurdle)

  6. {

  7. if(hurdle.name == hurdle)

  8. {

  9. speed = 0; // this way your chahracter will not move if it collides to hurdle

  10. }

  11. }


ss.png (12.6 kB)
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
avatar image
0

Answer by darknubis365 · Feb 01, 2018 at 02:42 AM

I am having some trouble with this right now as well trying to make NPC vendor's when walking up to purchase an item pressing W and walking forward i can push my NPC vendor out of place,its driving me crazy lol

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

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

how to make a character walk with touch in android 0 Answers

Making Character Stand? 1 Answer

Sprint Error script? 2 Answers

How to make a character stop going through the terrain? 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