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 spunktrumpet · Dec 15, 2013 at 10:20 PM · collisioncolliderdetection

Collision detection not working

I've got a cube with a player controller script attached, then I have multiple collision boxes with the cube as the parent object at points around the cube. My enviroment is also made up of cubes each with a collision box attached. What I am trying to do is see which of the collision boxes attached to my player has hit one of the other collision boxes outside of my player. Ie. the cube has 4 collision boxes, one on each 4 sides of the cube, if the front collision box has hit a collision box of another game object then do function. This is what I have so far. bcBottom is attached to the cube whilst floorBc is attached to the outside gameobject I am trying to create a collision between. If it has hit it then fwdMove = true, if not then it's false however it is never coming back as true only ever false.

     void OnColliderEnter(Collider bcBottom) {
     if (bcBottom.gameObject.tag == "floorBc") {
                     fwdMove = true;
             }
 }

 void Update () {

             if (Input.GetButtonDown ("VerticalFwd")) {
             if(fwdMove == true){
             amountToMove.y = 1f;
             transform.Translate (amountToMove);            
             } else {
                 fwdMove = false;
             }
 }                
 }
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by flaviusxvii · Dec 15, 2013 at 10:32 PM

OnColliderEnter should be OnCollisionEnter.

Comment
Add comment · Show 3 · 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 spunktrumpet · Dec 15, 2013 at 10:38 PM 0
Share

I realised that after I posted however it still makes no difference. Am I going some where wrong stupidly simple? If the boxcollider attached to the player is bcBottom and I want to check that it is hitting the collider with the tag floorBc. Is this the way I would go about it? Bare in $$anonymous$$d there are multiple box colliders attached to the player object.

avatar image flaviusxvii · Dec 15, 2013 at 10:42 PM 0
Share

I don't know enough about everything you have set up. Double check you have colliders attached to everything you want to collide.

avatar image spunktrumpet · Dec 15, 2013 at 11:09 PM 0
Share

I'm getting really confused here now after playing around trying to get this to work. Say I had a cube with no box collider but it had 4 box colliders attached to emptygameobjects, 1 on each of the cubes faces and they are within the cube as children so the cube is their parent. Each collider is tagged 1, 2, 3, 4 retrospectivley. If I wanted to check that collider 1 has hit another collider completely seperate of the player, say it was tagged as colliderEnviroment. Also none of the colliders have rigid bodies, how would I check that box collider 1 has hit that collider? When I'm searching for help I can only find help for instances where there is only 1 collider attached the to player directly and not as a child object. I'm getting pretty confused right now :/ Thanks for the help so far.

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

17 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

Related Questions

Unity Collison Problem 1 Answer

front check based on unity projects not working. 0 Answers

how do i correctly use a box collider 1 Answer

Enemy Detection Area 1 Answer

C# GameObject is not detecting collision with Character Controller 2 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