Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 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 /
  • Help Room /
avatar image
0
Question by Sofia0011 · Nov 24, 2015 at 05:18 PM · unity 5collisionplayertagslayer

Player should be able to go through Wall

Hi,

i am doing a game in which a player should be able to walk through walls. Walls are 3D cubes objects in my game. I can't just uncheck the "box collider" of the wall prefab, because I also have players who are monsters and who shall NOT be able to walk through walls, only human player can.I have tried different approaches, e.g. tagging the player and attaching a script to the wall which uses "if (collision.gameObject.tag == ""Player) {Physics.IgnoreCollision(...)}. I tried different layers for walls and players using "Physics.IgnoreLayerCollision..()..". But Nothing works. What am I missing?

Thanks!

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
0
Best Answer

Answer by Jessespike · Nov 24, 2015 at 05:46 PM

Edit -> Project Settings -> Physics

The Layer Collision Matrix defines how collisions on different layers will react.

Read more: Unity Manual - Layer Based Collision

.

Comment
Add comment · Show 1 · 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 Sofia0011 · Nov 24, 2015 at 06:31 PM 0
Share

thanks! I tried that and it worked. The weird thing is, that I can't hear my human players steps anymore and I can't use the controller properly to turn around as I could before.

avatar image
0

Answer by $$anonymous$$ · Dec 03, 2015 at 07:59 PM

OK< well here is something that depends also on what version of Unity you are using. For sake of argument I am going to assume the most recent.

Lets say your movement code looks like this;

  transform.Rotate(0, Input.GetAxis("Horizontal") * rotateSpeed, 0);
             Vector3 forward = transform.TransformDirection(Vector3.forward);
             float curSpeed = speed * Input.GetAxis("Vertical");

it will detect any mesh you have in scene as a player.

If you have something like this

 Input.GetAxis("Horizontal") * Time.deltaTime, 0f, moveSpeed * Input.GetAxis("Vertical") * Time.deltaTime);

it passes through most objects even with mesh colliders applied.

The other factor depends on if you are using a capsule collider on the person or a Character Controller collider. In most cases, simply checking them to trigger will allow you character to pass through objects, but leaving the colliders on enemies as unchecked will keep them from passing through said mesh collider set objects you placed.

So that's really the only two parts you need to check, the type of movement script and the collider type and its settings.

Hope that helps.

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 naveedkhan358 · Mar 03, 2018 at 07:57 PM

A game object can only be in one layer. The layer needs to be in the range [0...31] UnityEngine.GameObject:set_layer(Int32) Chapter1.WalkThroughWall:SetLayerToNotSolid() (at Assets/My script/Chapter1/WalkThroughWall.cs:25) Chapter1.GameManager_EventMaster:CallMyGeneralEvent() (at Assets/My script/Chapter1/GameManager_EventMaster.cs:18) Chapter1.TriggerExample:OnTriggerEnter(Collider) (at Assets/My script/Chapter1/TriggerExample.cs:22)

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

50 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

Related Questions

How to trigger animation from object colliding with another? 0 Answers

Jumping and collision issue 1 Answer

Collider2D not stopping when colliding with another Collider2D [Solved] 2 Answers

Special collision for players 1 Answer

Making a Game Save hitting a trigger 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