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 falconer · Apr 19, 2013 at 07:55 PM · colliderplanewheel colliders

Set a boolean to true once the wheel collides with two planes?

Hello, I have set a wheel collider to a car, and i have placed two planes along the ground which are tagged with "tag1" and "tag2". What i want to do is, I want to set a boolean variable to true, once the wheel passes through or collides with both the planes. Here's the code I've written, but it doesn't seem to work, donno why:

 var isFinished : boolean = false;
 var myWC : WheelCollider;
 function Update () {
 var hit : WheelHit;
 if(myWC.GetGroundHit(hit)) {
  if(hit.collider.gameObject.tag == "tag1"){
   if(hit.collider.gameObject.tag == "tag2")  {
    isFinished = true;
  }
  }
 }
 }

 
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 Raydaq · Apr 19, 2013 at 08:40 PM 0
Share

What are these? waypoints on a course? a parking spot? Is there a separate collider on each wheel?

Looks to me like these can never both be true in the same frame unless the two planes are overlapping.

avatar image falconer · Apr 20, 2013 at 03:52 AM 0
Share

well, these are planes as i mentioned above. What I want to achieve is, I'm making a racing game; I have made two planes as the finish line, the car should move over these two planes in sequential order i.e. first it should move over tag1 plane and then tag2 plane, then i want to set the isFinished (which indicates that the race is finished) to true. And yeah these are not overlapping.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Robble · Apr 19, 2013 at 09:16 PM

You are checking if the wheel has hit tag1 and tag2 at the same time as it will only hit one at a time the function will never return true.

I've tweaked your code so it should work but i would point out this code is very ugly and inefficient but its the best i can do without knowing more about how your project works. hopefully it will set you moveing in the right direction

 var isFinished : boolean = false;
 var myWC : WheelCollider;
 private var tag1Hit:boolean = false;
 private var tag2Hit:boolean = false;

 function Update () {
 
 var hit : WheelHit;
 if(myWC.GetGroundHit(hit)) {
     if(hit.collider.gameObject.tag == "tag1"){
         tag1Hit =true;
     }

     if(hit.collider.gameObject.tag == "tag2")  {
         tag2Hit =true;    
     }
 }
   isFinished = CaculateIsFinished();
 }

 function CaculateIsFinished():boolean{
     if(tag1Hit && tag2Hit){
       return true;
     }else{
       return false;
     }
 }

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 falconer · Apr 20, 2013 at 03:53 AM 0
Share

What I want to achieve is, I'm making a racing game; I have made two planes as the finish line, the car should move over these two planes in sequential order i.e. first it should move over tag1 plane and then tag2 plane, then i want to set the isFinished (which indicates that the race is finished) to true. And yeah these are not overlapping.

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

13 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

Related Questions

Mesh collider from 3d model not triggering collision with plane 1 Answer

Default plane collider doesnt work properly when stretched? 0 Answers

Changing thickness of plane collider in default plane... 2 Answers

How can I use raycasthit and collider raycast to hit only if the mouse position is over a specific object ? 1 Answer

2d plane falls through and half disapears when on terrain 0 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