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 SamualMeh · Sep 24, 2013 at 03:30 PM · inputscenemousechangedisable

Re-disable mouse input after scene change?

I am creating a simple game: 3 scenes, 3 character controllers, 3 enemies. I have it set so that right Mouse click takes you to the next scene but you can only advance once the enemy in the scene has been destroyed. It works fine for the first target but in the second scene I can freely move on without destroying the target. It seems like there's such a simple solution but I can't quite see it. I'm using JavaScript and using Raycast to destroy my enemies. I'm quite new to Unity so sorry if I ask any follow up questions aha. Any help would be great thanks:)

RClick_Enable Script:

 #pragma strict
 
 var canClick : boolean;
 
 function Start()
 {
     canClick = false;
 }
 
 function Update()
 {    
     if(RayCast_Target.objectDestroyed)
     {
         canClick = true;
     }
     
     if(canClick == true)
     {
         if((Input.GetMouseButtonDown(1)) && (Application.loadedLevel == (2)))
         {
             Debug.Log("Pressed right click.");
             Application.LoadLevel(3);
         }
         
         if((Input.GetMouseButtonDown(1)) && (Application.loadedLevel == (2)))
         {
             Debug.Log("Pressed right click.");
             Application.LoadLevel(3);
         }
     }
 }
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 oliver-jones · Sep 24, 2013 at 04:05 PM 0
Share

Alright, edit your post and copy/paste your code that you're using so we can see whats going on too

avatar image SamualMeh · Sep 24, 2013 at 04:12 PM 0
Share

What i'm thinking is maybe adding something that sets canclick back to false after the new scene has been loaded.

2 Replies

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

Answer by oliver-jones · Sep 24, 2013 at 04:33 PM

Well, looking at your script. You are checking to see if 'RayCast_Target.objectDestroyed', which I'm guessing gets called when you have killed an enemy, which means that as soon as you kill your first one, it will turn 'canClick' to true... Which you only want when you have killed all 3, right?

 var maxEnemy : int = 3;
 var killedEnemy : int = 0;
 
 function Update()
 {   
     if(RayCast_Target.objectDestroyed)
     {
        killedEnemy ++;
     }
 
    if(killedEnemy == maxEnemy){
    {
       canClick = true;
    }



The only issue here might be that the killedEnemy might increase every frame. I don't know how that 'RayCast_Target' is called.

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
avatar image
0

Answer by SamualMeh · Sep 24, 2013 at 04:38 PM

Ahh sorted it! I needed to add a

canClick = false; RayCast_Target.objectDestroyed = false;

to both of the

if((Input.GetMouseButtonDown(1)) && (Application.loadedLevel == (2))) {

and

if((Input.GetMouseButtonDown(1)) && (Application.loadedLevel == (3))) {

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

16 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

Related Questions

Disable, Enable a User Input? 1 Answer

How to get GameObject that is clicked by a mouse? 2 Answers

Projection to mouse position in isometric game 1 Answer

Switch Between Touch And Mouse Controls 0 Answers

Scene Change Collision 2 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