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 Vice_Versa · Apr 08, 2015 at 09:59 AM · unity 5rigidbodycollisionskinematicbox collider

Cant get Collisions to work

I know collisions have changed a little bit in unity 5 but i cant seem to get this to work at all

im making a 3d rail shooter, and there are objects on the ground that when the players ship collides with, are supposed to subtract health from the player.

the players ship is an empty game object, with the prefab for the ship as a child which has a rigidbody(isKinematic on) and a box collider(not trigger)

the object the player is colliding with is a prefab of an arch (that i removed the mesh collider from) this has a child which is an empty gameobject that i attached the rigidbody (isKinematic on) and the two scripts(one of which should decrease the players health) This emptyGameObject has 5 empty game objects as children, each of which has a box collider(each one is for a different part of the arch). the box colliders are currently not set to isTrigger.

these are the two scripts i attached to my parent game object that is holding all of the box colliders

 using UnityEngine;
 using System.Collections;
 
 public class DamagePlayerOnCollision : MonoBehaviour{
     public float damageAmount = 1.0f;
     public float coolDownTime = 1.0f;
 
     private bool inCoolDown = false;
     void onCollisionEnter()
     {
         Debug.Log ("COLLIDED!!!!!!!!!!!!!!!!!!!");
                 if (!inCoolDown) {
                         HealthManager.Instance.DamagePlayer (damageAmount);
                         inCoolDown = true;
                         Invoke ("Uncool", coolDownTime);
                 }
 
         }
     void Uncool()
     {
                 inCoolDown = false;
     }
 }


and here is the other one


 using UnityEngine;
 using System.Collections;
 
 public class DamagePlayerOnTrigger : MonoBehaviour{
     public float damageAmount = 1.0f;
     public float coolDownTime = 1.0f;
 
     private bool inCoolDown = false;
     void onTriggerEnter()
     {
         Debug.Log ("COLLIDED!!!!!!!!!!!");
                 if (!inCoolDown) {
                         HealthManager.Instance.DamagePlayer (damageAmount);
                         inCoolDown = true;
                         Invoke ("Uncool", coolDownTime);
                 }
         }
     void Uncool()
     {
                 inCoolDown = false;
     }
 }


i am aware that only one of these codes should be used for this to work, however, neither one of them does and Debug.Log never prints anything when the players ship collides with the object. What do i need to do for the game to recognize the collisions(Again, I am using Unity 5, not 4).

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 Vice_Versa · Apr 14, 2015 at 09:19 PM

so i figured out what was wrong. i spelled onCollisionEnter with a lowercase o it shouldve been OnCollisionEnter()

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
1

Answer by Digital-Phantom · Apr 08, 2015 at 10:00 AM

Firstly, try changing the box colliders to isTrigger.

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
1

Answer by Johnz1234 · Apr 08, 2015 at 10:48 AM

Trigger your object and its shoud work fine

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 Vice_Versa · Apr 08, 2015 at 05:13 PM 0
Share

so i tried triggering the objects then turning those off and triggeringthe object, neither worked. then i tried removing the empty game object holding all the colliders and made them children of the main object holding the prefab. if i have is$$anonymous$$inemetic off, use gravity off, and i jam the arch halfway through the gameplane, it collides(bounces off) of the ship without flying through the air, however neither of my scripts are being run when the collision happens. im using the methods onTriggerEnter and onCollisionEnter should i be trying to use something else?

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

seeking collision scenario solution : falling anvil vs. player 0 Answers

Rigidbody goes crazy when isKinematic is false 1 Answer

How do I change Raycast's direction based on movement input? 1 Answer

Collisions when pushing object 1 Answer

Kinematics: Trying to get an object to land at a known point 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