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 CJGames · Dec 23, 2014 at 04:29 PM · javascriptcollisioncolliderkill player

What's wrong with my code? (Collision, JS)

In my FPS you have like a plataform and if you fall from it you're supposed to die when you hit the ground, so i made a box with a collider (removed mesh renderer and added "FallDead" tag) then i called this is my CharacterLife script (inside the Player GameObject):

 function OnCollisionEnter (collision : Collision){
     if(collision.gameObject.tag == "Enemy"){
         totalHealth = totalHealth - 10;
     }
     if(collision.gameObject.tag == "FallDead"){
         totalHealth = 0;
     }
 }

When i collide with my enemy (with the tag "Enemy") my player loses 10 health, and this part works perfect, but the second one, checking if the player hits the ground, is not working.

The player has no Rigidbody but the Ground game object has (with freezed rotation and position, and no gravity) and I CAN'T add a rigidbody to my player, i tried that once and the physics went crazy everything started flying and stuff like that...

Also I apologize about my english i'm not american.

Comment
Add comment · Show 1
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 tanoshimi · Dec 23, 2014 at 04:31 PM 0
Share

Well, if the first part works perfectly but the second part does not, that rather suggests that your ground is not tagged with the "FallDead" tag...

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by flapy-monkey · Dec 23, 2014 at 05:05 PM

I think triggle collider enough, you can try it. and maybe you can check here alt text


qq20141224-2@2x.jpg (30.9 kB)
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 CJGames · Dec 23, 2014 at 06:44 PM 0
Share

how to I get this screen? how to I add this?

avatar image CJGames · Dec 23, 2014 at 06:53 PM 0
Share

found how to reach this screen, and $$anonymous$$e is exactly like yours

avatar image
0

Answer by xwheat32x · Dec 23, 2014 at 05:02 PM

Under the script "(shape) Collider" on your trigger collider, you will see a check box called "Is Trigger". Check that box.

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 tanoshimi · Dec 23, 2014 at 05:02 PM 0
Share

That would stop OnCollisionEnter being called completely....

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

28 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

Related Questions

OnCollisionEnter Push Object Problem 0 Answers

Unity 2D Colliders not Colliding 2 Answers

Disable a diffrent collision 1 Answer

Collision with renderer.enabled? 0 Answers

Sound on collision 3 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