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 Oobi23 · May 26, 2013 at 06:17 AM · order-of-executionmissions

One Action/Mission at a time

Hi there, I have a currently working code with a timer that starts and finishes on trigger and on collision respectively. But I am having trouble coding up how to make sure the character has to finish one mission to move on to the next.how will I go about coding this. So basically finishing HasMission then only being able to activate HasMission1 many thanks in advance

 if (Physics.Raycast (transform.position,dwn,hit, .5)) {
     var t:Timer;
     if(hit.collider.gameObject.tag=="HasMission"){
         Debug.Log("has mission");
         if(!showingMission){
             showingMission=true;
             t=GameObject.Find("Timer").GetComponent("Timer") as Timer;
             t.startTimer();
             
         }
     }else if(hit.collider.gameObject.tag=="EndMission"){
     
     }
 
                     
 }
 if (Physics.Raycast (transform.position,dwn,hit, .5)) {
     if(hit.collider.gameObject.tag=="HasMission1"){
        Debug.Log("has mission");
        if(!showingMission2){
          showingMission2=true;
          t=GameObject.Find("Timer1").GetComponent("Timer") as Timer;
          t.startTimer();
  
        }
     }else if(hit.collider.gameObject.tag=="EndMission1"){
  
     }
  
  
 }
 
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 robertbu · May 26, 2013 at 06:50 AM

I'm not completely sure what you are doing here, but I think you do something like this:

 if (GameObject.FindObjectWithTag("EndMission") && Physics.Raycast (transform.position,dwn,hit, .5)) {

So the second Physics.Raycast would only be reached if showingMission was true (i.e. the first mission is started) and there is no game object with the "HasMission" tag.

Comment
Add comment · Show 3 · 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 Oobi23 · May 26, 2013 at 07:02 AM 0
Share

Wouldn't it make sense to make sure the character is unable to start next mission until End$$anonymous$$ission has happened and stopped the timer?..(don't worry about the timer, It's working fine).. and that bit of coding doesn't seem to work, it disables the coding. I am just unsure about how to code this up.. :/

avatar image robertbu · May 26, 2013 at 07:13 AM 0
Share

So I changed the logic to use "End$$anonymous$$ission". I don't see anything here stopping the timer nor do I know how to check it based on the code above.

avatar image Oobi23 · May 26, 2013 at 07:18 AM 0
Share

This is the timer script that I am currently using and works just fine.

 private var doTimer:boolean;
 private var startTime:float;
 private var elapsedTime:float; 
 function Start () {
 doTimer=false;
 }
 
 function Update () {
     if(doTimer){
         elapsedTime=Time.time-startTime;
         GetComponent(GUIText).text = (elapsedTime).ToString("f2");
     
     }
 }
 
 
 function startTimer(){
     startTime=Time.time;
     doTimer=true;
 }
 
 function stopTimer(){
     
     doTimer=false;
     return parseInt(elapsedTime);
 }

and this is the End$$anonymous$$ission attached to one of the Tiles #pragma strict

 function Start () {
 
 }
 
 function Update () {
 
 }
 
 
 function OnCollisionEnter(o:Collision){
     if(o.gameObject.name=="EndBox"){
         var charScript:$$anonymous$$ovewithRaycast=GameObject.Find("CharContainer").GetComponent("$$anonymous$$ovewithRaycast") as $$anonymous$$ovewithRaycast;
 
         if(charScript.isShowing$$anonymous$$ission()){
                 var t:Timer;
         t=GameObject.Find("Timer").GetComponent("Timer") as Timer;
             var timeTaken:int=t.stopTimer();
             Debug.Log("time taken was "+timeTaken);
         }
         
     }
     
     
 }

Now what do you think? So, everything in the game functions without flaws, but I want to order the flow of missions..

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

How can I make Game Objectives? 1 Answer

What is the order of execution in a for loop? 1 Answer

When do constraints, like ParentConstraint and AimConstraint, evaluate? 1 Answer

Best way to store / activate levels in a game? 1 Answer

Referencing instantiated player in camera's Start() 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