Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Futureless · Jul 03, 2016 at 06:29 PM · scripting problemtrigger

OnTriggerEnter() is occasionally not occurred

I am making some kind of casual sport game with some rhythm-tap contents.

I tried to make a system of touching to decide what score you get for that trial.

A target pad comes down from top, and there is a "node". If you touch right in time(when the node is in the target area), it will gives you certain amount of score.

alt text the dark green-white area is target, and the white line under red person is node.

I have named dark-green area "pass", light green area "good", and white area "perfect".

And I have created a code

 using UnityEngine;
 using System.Collections;
 
 public class NodeCtrl : MonoBehaviour {
 
     public GameMgr gameMgr;
     public int score = 0;
 
     void Awake(){
         gameMgr = GameObject.Find ("GameMgr").GetComponent <GameMgr>();
     }
 
     void OnTriggerEnter(Collider coll){
         if (coll.CompareTag ("PERFECT")) {
             Debug.Log("perfect");
             score += 1;
         }
         if (coll.CompareTag ("GOOD")) {
             Debug.Log("good");
             score += 1;
         }
         if (coll.CompareTag ("PASS")) {
             Debug.Log("pass");
             score += 1;
         }
         coll.enabled = false;
     }
 
     public void SendBackScore (){
         Debug.Log (score);
         //GameObject.Find ("GameMgr").GetComponent<GameMgr>().Call(score);
         gameMgr.Call (score);
         score = 0;
     }
 }

However the console log occasionally says that I have got "miss"(which is 0 of score) when appropriately matching the node into target area. It happens about once in 5~15 trials randomly. By checking with Debug.Log(), it seems like to be that the OnTriggerEnter() part of my code does not work properly.

What can I do for solving this?

question.png (23.8 kB)
Comment
Add comment · Show 2
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 · Jul 03, 2016 at 06:37 PM 0
Share

Where's the code that prints "miss"? What part of this code checks that you tapped in time?

avatar image Futureless · Jul 04, 2016 at 07:13 AM 0
Share

The code that prints miss comes from Call(int score) in other script. It basically prints out "perfect", "good", "pass", "miss" by the score in parameter: 3 for perfect, 2 for good, 1 for pass, and 0 for miss

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by KrabyGame · Jul 03, 2016 at 11:41 PM

I don't really understand when/how you get the "miss", but try to set "Collision Detection" to "Continuous" or "Continuous Dynamic" on the rigidbody. It often helps to prevent problems with collisions/collider.

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 Futureless · Jul 04, 2016 at 05:38 AM 1
Share

it get miss when the target and node never matches if touched

I have tried both options for collision detection and the problem was still existing

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

Trigger Sound more than Once 0 Answers

How to disable player gravity 2 Answers

Enable Trigger On Trigger 1 Answer

transpoter not working! 1 Answer

Trigger AI character when certain condition is met 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