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 timeshift117 · Apr 24, 2013 at 02:28 PM · charactercontrollertagoncollisionenterjavascript class

Collision with character controller and cube not working

Hi, I have a character controller with the tag "Player" and a cube called door with the tag "Door", this function isn't working, it is in the doorPhysics.js script for the door. I am trying to simulate a door being opened when the "Player" hits the "Door". Even when I remove the if statement the Debug.Log doesn't work. And I am sure the doorPhysics.js script is linked to the door.

 function OnCollisionEnter(col : Collision){
 
     if (col.gameObject.CompareTag == "Player"){
     
         Debug.Log("the door should have rotated");
            transform.position = Vector3(-.5,0,0);
            transform.rotation = Quaternion.Euler(0,-90,0);
     }
 }
Comment
Add comment · Show 4
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 Glister · Apr 24, 2013 at 02:38 PM 1
Share

Look at my comments to the question asked right here

$$anonymous$$y first comment adds a second print to test for the colision before the IF statement. $$anonymous$$y second comment links a couple other places where they talk about character controller collision.

avatar image timeshift117 · Apr 24, 2013 at 02:43 PM 0
Share

I just tried it, the print statement does not show up. I'll check out the link

avatar image Glister · Apr 25, 2013 at 03:00 PM 1
Share

Did you ever read through that link and some of the materials it links to? If so did you try any of those solutions specifically the linked materials pointing to the character controller collisions? Unity handles character controller collisions differently than other colliders. You will need to use one of the other methods to capture the collision.

avatar image yuyu2172 · Sep 09, 2014 at 01:37 PM 0
Share

This link explains character controller by comparing it with similar component 'rigid body'. https://www.youtube.com/watch?v=AEPI5rmg3XY

You may want to check these if OnCollisionEnter starts with collision of non-character objects, but not with character object.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by MrSteve1 · Apr 24, 2013 at 04:19 PM

You don't need CompareTag if this script is attached to the door. just col.gameObject.tag == "Player"

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 timeshift117 · Apr 25, 2013 at 06:49 AM 0
Share

still is not working

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

14 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

Related Questions

OnCollision messages don't work with Character Controller? 1 Answer

Two Character Controllers Colliding... 0 Answers

Ammo crate collision 2 Answers

Question regarding Character Controller 1 Answer

OnControllerColliderHit -> GetComponent on collided object not working 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