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 Adcano · Nov 28, 2014 at 08:36 PM · collisioncharactercontroller

OnCollisionEnter/Stay not working when jumping on Enemy

Hi all!

I'd like to know if anyone knows why my collisions (on enemy) stops detecting my player when i jump on it (and stay there)

So the case is:

Player:

2d-SpriteRenderer

CharacterController

2 Scripts - 1 controls movement, another lifebars

Enemy:

2d-SpriteRenderer

Rigidbody

Sphere collider (As collider, physics purpose)

Sphere collider (As trigger, enemy "Aggro" zone)


So, when i move Player and enter "aggro" zone, enemy comes to me. When both collide (It's working) my healthbar get's down, but...

If i jump on the enemy, the player just stand here, on the enemy (so there are some sort of collision) but OnCollisionEnter && OnCollisionStay just don't work.

¿Anyone solved something like this?

I'll attach some screenshots ...

alt text

OnCollisionEnter/Stay working - My health goes down.

alt text

When i stay ON the enemy, OnCollisionEnter/Stay stops working - My health isn't moving anymore..

The code in the Enemy script for collision...

 void OnCollisionStay(UnityEngine.Collision other){
         if (other.gameObject.tag == "Player") {
             GameObject player = GameObject.FindGameObjectWithTag ("healthBar");
             barraVida playerScript = player.GetComponent<barraVida> ();
             playerScript.health -= 3;
             Debug.Log ("STAY"+playerScript.health);
         }
     }

Thanks all !!! :)

prob2.jpg (336.2 kB)
prob3.jpg (327.7 kB)
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

0 Replies

· Add your reply
  • Sort: 

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

2 People are following this question.

avatar image avatar image

Related Questions

CharacterController and Animator components together damage isGrounded variable behaviour 0 Answers

Building project (web or win) breaks charactercontroller 0 Answers

My Character controller is being push a little bit when i'm about the get the coins. How can i possibly detect collision and destroy the coins without actually getting affected by the colliding physics? 1 Answer

Sphere Collider doesn't move after collision with Character Controller 1 Answer

IsGrounded working to slow? 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