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 Unoriginal username · Jan 23, 2015 at 09:32 AM ·

randomized jumpscare not working!

hello ive made it so that when the player collides with the enemy, a random jumpscare occurs. The thing is, the player just collides with the enemy normally as if it was a gameobject. please help me. i got no errors.

my code:

 var mainCam : Camera;
 var jsCam : Camera;
 var jsCamOne : Camera;
 var jsCamTwo : Camera;
 var overCam : Camera;
 var player : GameObject;
 private var Jumpscare = false;
 
 function Update ()
 if (Jumpscare = true)
 {
     gameOver();
 }
 
 function OnTriggerEnter (theCollider : Collider)
 {
   if (theCollider.tag == "Player") {    
   
   var randomnumber = Random.Range(0,3);
   
   {
     if(randomnumber == 0) {
     Jumpscare = true;
     jsCam == true;
     jsCamOne == false;
     jsCamTwo == false;
     mainCam == false;
     overCam == false;
     gameOver();
     }
 
     if(randomnumber == 1) {
     Jumpscare = true;
     jsCamOne == true;
     jsCamTwo == false;
     jsCam == false;
     overCam == false;
     mainCam == false;
     gameOver();
     }
 
     if(randomnumber == 2) {
     Jumpscare = true;
     jsCamTwo  == true;
     jsCamOne == false;
     overCam == false;
     jsCam == false;
     mainCam == false;
     gameOver();
         }
     }
 }
 
 function gameOver ()
 {
     yield WaitForSeconds(1);
     jsCam == false;
     jsCamTwo == false;
     jsCamOne == false;
     overCam == true;
     mainCam == false;
 }


Comment
Add comment · Show 8
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 jakovd · Jan 23, 2015 at 09:57 AM 0
Share

problem 1. Line 10. You are using assignment operator = ins$$anonymous$$d of equality operator ==.

avatar image PorkMuncher · Jan 23, 2015 at 09:57 AM 0
Share

jsCam == false just compares the values and returns true or false.

If you want to enable/disable cameras use jsCam.enabled = true/false;

== is for comparison = is for assigning a value

avatar image jakovd · Jan 23, 2015 at 09:59 AM 0
Share

problem 2. You are calling gameover function from both Update and OnTriggerEnter. Do you want game over to be called more than once per collision?

avatar image jakovd · Jan 23, 2015 at 10:00 AM 0
Share

problem 3 (well actually still problem 1) You are using == all over where you should be using =.

avatar image jakovd · Jan 23, 2015 at 11:37 AM 0
Share

problem 4. If you are setting some variable to the same value in all three if-cases (like Jumpscare, overCam, mainCam), you might as well write it down outside of that if's. Do not repeat your code all over.

Show more comments

0 Replies

· Add your reply
  • Sort: 

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

Trying to Tackle ledge climbing with blender animated Character!! 0 Answers

Running Unity FREE license on school computers 1 Answer

Trying to make a score script that shows the score through a GUIText object. 0 Answers

Reference error -_- Annoyed please help 1 Answer

Collider has illegal parameters 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