Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 Bluenipper · Nov 21, 2013 at 07:35 AM · javascriptcollidertagcontrollercolliderhit

Collide script not working...

I am coding in javascript and added some stuff to my move script so that when the player falls off the terrain it would hit a large stretched out cube which I tagged "fallout" and would cause the player to "die" and respawn back at the start on the terrain. Here is the script:

 var speed : float = 3.0;
 var rotateSpeed : float = 3.0;
 private var dead = false; 
 
 function OnControllerColliderHit (hit : ControllerColliderHit)
 {
     if(hit.gameObject.tag == "fallout")
     {
         dead = true;
 
     }
     
 }
  
  
 function lateUpdate()
 {
     if(dead)
 {
 transform.position = Vector3(250.6392,7.611946,19.88934);
 
 gameObject.Find("Main Camera").transform.position = Vector3(0,0,-100);   
 
 dead = false;
     }
 }
  
 @script RequireComponent(CharacterController)



I removed the move section of the script so it only includes the collide sections. At the moment if I run my game and go off the edge the player just lands on the "fallout" and moves around on it, it doesn't respawn like it is supposed to.

The player is a Cylinder scaled (15,1,15) and has a character controller and rigid body. The "fallout" is a cube scaled (5000,5,5000) and has a box collider.

Any help would be greatly appreciated and I need to work this out ASAP as it is for a project that needs to be completed tomorrow.

Thanks.

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by GEWLAR · Nov 21, 2013 at 09:17 AM

Is the box collider of the "fallout"-cube marked as "Collider is trigger" ?

If yes, try this script:

 function OnTriggerEnter(otherObj: Collider){
 
         if (otherObj.tag == "Player"){ 
             dead=true;
         }
 }

Attach it to the "fallout"-cube and attach the "Player"-tag to your player. Tell us how it goes

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 Bluenipper · Nov 21, 2013 at 12:48 PM 0
Share

No, thanks that fixed it.

avatar image GEWLAR · Nov 25, 2013 at 02:30 PM 0
Share

You should accept the answer. This way your question isn't visible in unamswered questions anymore. This would help others to see which questions are answered and which aren't.

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

17 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

Related Questions

How can to convert it on c#? 1 Answer

Collider script refuses to work 1 Answer

Footstep Audio Check Collider Hitting Floor 1 Answer

Need some help an object collider that stops a timer then displays it on another scene 1 Answer

RaycastHit collider not showing correct tags 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