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 NewUser14 · Sep 02, 2012 at 04:23 PM · deathfall

Fall Death

Im trying to kill the player via falling. Does this make sense or am i totally off?

private var dead = false;

function OnControllerColliderHit(hit : ControllerColliderHit) { if(hit.gameObject.tag == "FallDeath") { dead = true; } }

function Update() { if(dead) { transform.position = Vector3(0,4,0); } }

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 RecChem · Sep 02, 2012 at 04:32 PM 0
Share

not too familiar w/ js but looks like you're using bool values for "var" which should be for numbers. try using bool type in your declare, or could do a check for 0 or 1 for your true/false check. may be some other issues, but that may get you started hopefully

avatar image fafase · Sep 02, 2012 at 04:39 PM 0
Share

In Js, var is the keyword for declaring a new variable of any type. What is missing in his declaration is the type which is not required in Js if you provide enough information for the compiler to assume the type. As he gives = false; the compiler knows it means boolean. Should he have given = 22;, the compiler makes it an integer. C# would not let you do so which makes me think you are used to C#.

avatar image by0log1c · Sep 02, 2012 at 04:46 PM 0
Share

Also, in C#, var is not restricted to numbers, but to any type, as long as the variable type can be deter$$anonymous$$ed at compile-time.

avatar image fafase · Sep 02, 2012 at 06:15 PM 0
Share

Oh yeah, it does. I am not really to using this one with C#...

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by fafase · Sep 02, 2012 at 04:29 PM

What if you try it, does it work? if it works, then it is the way but it probably does not work as you never set the dead boolean back to false so your guy is always sent back to the origin.

 function Update() { 
   if(dead) { 
     transform.position = Vector3(0,4,0); 
     dead = false;
   }
 }
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

10 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

Related Questions

Make a script look for something an an other script 1 Answer

How can I lose health when my enemy collides with the player? 1 Answer

Environmental Death script 1 Answer

Death upon health = 0 2 Answers

Scripting a Death Fall 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