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 djfatsteve2 · Jul 11, 2013 at 07:58 PM · collisioncolliderscenes

Collision Help Please

So I've searched far and wide for a solution to my problem and seems I'm at a loss. If you rage me for not searching hard enough, I'll bash your face in. I'm at my wits end on this issue, and has halted my games development.

On a lighter note... My character "Player" is named & tagged as "Player"(Seen below) -Ridgedbody applied, and "CollisionChange1.js" is attached to him. alt text

CollisionChange.js :

 #pragma strict
 
 function OnCollisionEnter(other : Collision){
     if(other.gameObject.name == "Cave1Entrance"){
     Debug.Log("Collided with " + other.gameObject);
         //Application.LoadLevel("cave1");
     }
  
     if(other.gameObject.tag == "Cave1Entrance"){
         //Application.LoadLevel("cave1");
     Debug.Log("Collided with " + other.gameObject);
     }
 }
 

I'm using a 1x1 cube for my "Cave Entrance" until I can get this working properly, then I'll delete this 1x1 cube and rename my original cave entrance to "Cave1Entrance". (Example Below of names/tags/etc)

alt text

Yes, my build settings are completed. Eyden (0), cave1 (1)

Ugh, a little help would be a huge relief... Thanks guys.

Comment
Add comment · Show 6
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 Lockstep · Jul 11, 2013 at 08:18 PM 0
Share

Is OnCollisionEnter beeing called? Check this with a Debug statement at the very top of the function, not inside of the if condition.

If the first debug shows up, but the second doesn't, then the collision works fine but the if condition is false. This would mean that you likely misspelled the name of your cave entrance gameobject.

If neither is shown the function does not get called. This can have various causes: $$anonymous$$ake sure both your player and the cave entrance have a collider attatched. Also make sure they can collide. Check out the collision matrix as reference.

A generall advice for organization purpose: Have your cave enter logic on the entrance not on the player. Just give it some OnCollision/OnTrigger statement and check if the tag of the other thing is player. That way every thing knows what it does on its own and the player does not have a list of a hundred conditions to check what should happen on collisions.

avatar image djfatsteve2 · Jul 11, 2013 at 08:51 PM 0
Share

So this is what I've changed my code to.

      #pragma strict
         
         function OnCollisionEnter(other : Collision){
         Debug.Log("Collided with " + other.gameObject);
             if(other.gameObject.name == "Cave1Entrance"){
             Debug.Log("Collided with " + other.gameObject);
                 //Application.LoadLevel("cave1");
             }
          
             if(other.gameObject.tag == "Cave1Entrance"){
                 //Application.LoadLevel("cave1");
             Debug.Log("Collided with " + other.gameObject);
             }
         }
 

  • I have a rigidbody on my Player (Enabled)

  • Box collider is on my cave entrance (Enabled)

  • The CollisionChange.js is on my "Player"

  • Box is named "Cave1Entrance", tagged "Cave1Entrance" (No spelling errors.)

So tell me, what could POSSIBLY cause this to mess up if there are no other factors?!?!?

I've tried ticking "IsTrigger", but the Collider seems void, i can walk through it, nothing happens.

I've read the entire Physics Components Guide and to no avail.

It's a shame that I've spent 8 weeks on a full planet level design, and when it comes time to add a new planet, issues. I'm nearly to the point of deleting the entire project and saying F*&^ it.

avatar image Brian@Artific · Jul 11, 2013 at 08:58 PM 0
Share

What kind of collider is on your player and how fast is it moving? Also, is the cave entrance marked static?

avatar image djfatsteve2 · Jul 11, 2013 at 09:09 PM 0
Share

I've got a capsule collider on my character (I've tried capsule, box, sphere, rigidbody, everything.) 8 $$anonymous$$ove speed according to the "PlatformInputController" And there is a box collider on my cave entrance.

Neither is static.

avatar image djfatsteve2 · Jul 11, 2013 at 09:12 PM 0
Share

Also, the Debug.Log isn't showing any results of OnCollisionEnter being called.... Hmmm.... It's the only other script on my player besides the PlatformInputController.

Show more comments

1 Reply

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

Answer by Brian@Artific · Jul 11, 2013 at 09:24 PM

EDIT: This answer has been changed based on the new information in your comment regarding use of the CharacterMotor script:

The CharacterMotor script requires a CharacterController, which is a special type of collider. To detect collisions resulting from calls to the CharacterController's Move method, you'll need to use the OnControllerColliderHit method instead of OnCollisionEnter.

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 djfatsteve2 · Jul 12, 2013 at 12:57 AM 0
Share

You sir, $$anonymous$$@Floppy, are a God.

Worked a charm. Thanks a billion. Sol Source development continues!

avatar image Lockstep · Jul 12, 2013 at 04:15 PM 0
Share

Can you please accept this answer then? This will help people with the same problem find the answer faster and people who want to help won't run into a solved problem. Thanks.

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

super mario pipe physics? 1 Answer

Trouble with OnCollisionEnter and Exit 1 Answer

Trigger Enter and Exit not working properly? 2 Answers

destroy touch the screen on gameobject in camera 0 Answers

Audio play when object hit collision. 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