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
1
Question by jack_sparrow · Sep 17, 2012 at 11:38 AM · collisioncolliderballfootball

Detect when object in not colliding with collider.

hi frnds

i m wondering, is there any way to detect that object in not colliding. i m making penalty shootout. so when my ball enters in goal post texture will appear "GOAL". and when ball is outside of goal post after kick it will display "Miss"

thanx regards

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 theUndeadEmo · Sep 17, 2012 at 11:48 AM 1
Share

simple way is to add some triggers around the goal post, same way to when it hits the net when ever they hit those it will display miss, you'll need 3 more triggers one on the left of the goal post, one on the right and one on the top

avatar image jack_sparrow · Sep 17, 2012 at 12:41 PM 0
Share

thanx for replay theUndeadEmo and Fattie

i have already tried but having problems like.

when ball goes inside goalpost and bounce back to missed collider this will display both texture."GOAL And $$anonymous$$issed"

and there's area between goal keeper and player. if player kick slow and ball stops before it reach to goal post. then how can i detect that it is miss.

Thanx again

avatar image Leandro247 · Sep 17, 2012 at 01:07 PM 1
Share

You can make a timer (in code), and if the ball dont get anywhere at the end of the timer, it says miss (or whatever you want). I am new to coding, and i never had to make a timer so i forgot how to make it. I think there is a page explaining it in unity scripting reference, "Overview" section. Alternatively you can make the player lose if the goal keeper touches the ball, but if the player kicks the ball very slowy but far from the goal keeper it probably will not touch it, that depends on your AI.

avatar image jack_sparrow · Sep 17, 2012 at 02:25 PM 0
Share

thanx Leandro247

that's exactly what i thought. and asked this que..

and Fattie

my GOAL collider is already inside goal pose where NET is. still getting prob

isn't there is any code which can detect that object is not colliding with GOAL collider.

thanx again guys

3 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

Answer by Fattie · Sep 17, 2012 at 02:19 PM

box collider shown in red.

alt text

goal!

alt text

not goal !

Was mentioned, how to do a timer?

 person kicks the ball ... then call this:
 Invoke( "DisplayNoGoal" 1.0 );
 
 function goal()
  {
  person does in fact get a goal
  ie the trigger (red) was triggered
  CancelInvoke( "DisplayNoGoal" );
  actually yell "goa"
  }
 function DisplayNoGoal()
  {
  display something like you missed!
  }



but.jpg (23.1 kB)
notbut.jpg (34.7 kB)
Comment
Add comment · Show 6 · 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 jack_sparrow · Sep 21, 2012 at 06:13 AM 0
Share

hey Fattie sorry for late replay i have que. those green boxes are also a collider ??

or only the red one.??

avatar image jack_sparrow · Sep 21, 2012 at 06:49 AM 0
Share

ok.. thanx

avatar image jack_sparrow · Sep 21, 2012 at 10:11 AM 0
Share

sure.

but i having little prob here .

can't cancel invoke. it everytime execute the function in invoke. even if i goal.

in goal collider i i called goal function witch include CancelInvoke . but i don't why its not working.

am i missing something ??

avatar image Fattie · Sep 21, 2012 at 10:14 AM 0
Share

hoenstly this question is answered, nobody will look at it any more

I suggest you start NEW QUESTION, "problem with cancelling on goal" and carefully INCLUDE YOUR COD$$anonymous$$

I am sure someone will answer that new question very fast.

I hope it helps!

avatar image aksh2143 · Sep 10, 2015 at 09:09 AM 0
Share

@Fattie What if the ball hits on the GoalPost ans bounces back? I mean there is no collider/trigger befor the goal post so, if the the ball hits on solid frame of goal post and bounces and returns to the player side, it would be a miss, still not to be counted. How to deal with it?

Show more comments
avatar image
1

Answer by harko12 · Sep 17, 2012 at 07:53 PM

The only way I could think of checking that an object was NOT colliding is to go through the OnColliderEnter and OnColliderExit and set a flag when you are collided with the thing you want to check.

kind of like

 void OnCollisionEnter(Collision collisionInfo)
 {
         if (collisionInfo.gameObject.CompareTag("ColliderYouWantToCheck"))
         {
             bool IAmCollidedWithCollider = true;
         }
 }
 void OnCollisionExit(Collision collisionInfo)
 {
         if (collisionInfo.gameObject.CompareTag("ColliderYouWantToCheck"))
         {
             bool IAmCollidedWithCollider = false;
         }
 }

That said, that probably isn't the most efficient way, but it seems like it would work.

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 jack_sparrow · Sep 18, 2012 at 05:29 AM 0
Share

thanx harko

i will try.

avatar image Hims · Sep 21, 2012 at 10:51 AM 0
Share

when the ball collides with the Goal collider it should cancel the DisplayNoGoal()

function OnTriggerEnter(hit : Collider){ if(hit.gameObject.tag == "Ball") {

        CancelInvoke("DisplayNoGoal");// this function is called from here when person does in fact get a goal..to cancel the DisplayNoGoal()
 }

}

// when the ball is kicked the Invoke function executes as following. if(countBalls.ballcount==1){

       Invoke( "DisplayNoGoal", 3.0);
        }


function DisplayNoGoal() { print("goal missed"); goal$$anonymous$$issed.enabled = true; } the problem here is when the person kicks the ball the invoke function executes and delay for 3 seconds but even if the goal is done by the person the invoke function is not getting canceled...

avatar image
0

Answer by aksh2143 · Sep 10, 2015 at 09:10 AM

What if the ball hits on the GoalPost ans bounces back? I mean there is no collider/trigger befor the goal post so, if the the ball hits on solid frame of goal post and bounces and returns to the player side, it would be a miss, still not to be counted. How to deal with it?

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

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

15 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

Related Questions

Ball getting slow down in collision 0 Answers

The ball getting slow down and slicing. 0 Answers

Terrain collision problem 1 Answer

Collision Enter one of the objects ? 1 Answer

How to detect child object collisions on parent 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