Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by CubicPro · Jun 03, 2016 at 12:21 PM · camerascripting problemerrorbugswitch

Camera Switch error

Hi,

I trying to make a dialog system inside my objectives but I have a script problem when the script try to change from one camera to another..

in my game I set the objectives to a int value, when we press play start a cutscene with 16 seconds.. the player camera, the dialogue camera, the player canvas with the buttons and the dialogue canvas are disabled by ( gameobject.active = false; ) and all works fine.. after the cutscene the player camera and canvas turn active = true; and the cutscene camera, cutscene canvas, turn false and the dialogue still false.. so far all works..

so the player have to acomplish the first objective turning objective int value from 0 to 1.. in this moment the player camera, player canvas, have to turn false, and the dialogue camera and canvas have to turn true and show in the game scene.. and that is the problem.. the player canvas and camera dont turn false.. and after a seconds the player camera and the dialogue camera start to change from one to another every frame..

I already try a lot of things and dont know how to resolve.. here is the code I using.. I resumed.. have no errors..

void Start (){ (just for fix the visualization)

using UnityEngine; using System.Collections; using UnityEngine.UI;

public class MISSAO5: MonoBehaviour {

  int Objective;
  float Distance;
  GameObject portal;
  GameObject PlayerCam;
  GameObject CutSceneScreen;
  GameObject CutSceneCam;
  GameObject LevelScreen;
  bool CutScene;
  GameObject Avatar1;
  GameObject Avatar2;
  GameObject Dialog1;
      ....
      GameObject Dialog5;
  GameObject DialogScreen;
  GameObject DialogCam;
  int DialogInt;
  void  Start (){
      portal = GameObject.Find("PORTAL");
      PlayerCam = GameObject.Find("ThirdPersonCAM");
      CutSceneScreen = GameObject.Find("CUTSCENESCREEN");
      CutSceneCam = GameObject.Find("CUTSCENECAM");
      LevelScreen = GameObject.FInd("LEVELSCREEN");
      Avatar1 = GameObject.Find ("AVATAR1");
      Avatar2 = GameObject.Find ("AVATAR2");
      Dialog1 = GameObject.Find ("DIALOG1");
          ....
          Dialog5 = GameObject.Find ("DIALOG5");
      DialogScreen = GameObject.Find("DIALOGSCREEN");
      DialogCam = GameObject.Find("DIALOGCAM")
          PlayerCam.active = false;
      LevelScreen.active = false;
      DialogScreen.active = false;
      DialogCam.active = false;
      CutScene = false;
  }
  IEnumerator cutscene()
  {
      yield return new WaitForSeconds (16);
      LevelScreen.active = true;
      CutSceneCam.active = false;
      CutSceneScreen.active = false;
      PlayerCam.active = true;
  }
  void  Update (){
      if (CutScene == false) {
          StartCoroutine (cutscene ());
      }
      if (Objective == 0) {
          Distance = Mathf.FloorToInt (Vector3.Distance (GameObject.Find ("SNAKE").transform.position, transform.position) / transform.lossyScale.magnitude);
          if (Distance <= 1) {
              Objective = 1;
          }
      }
      if (Objective == 1) {
          Dialogue ();
      }
      2...3...4..
  }
  public void Dialogue()
  {
      
  PlayerCam.active = false;
  DialogCam.active = true;
  LevelScreen.active = false;
  DialogScreen.active = true;
  DialogInt = 1;
  if (DialogInt == 1) {
      Avatar2.active = false;
      Dialog2.active = false;
      Dialog3.active = false;
      Dialog4.active = false;
      Dialog5.active = false;
      Avatar1.active = true;
      Dialog1.active = true;
      2....3....4....5..
  }
  if (DialogInt == 6) {
      PlayerCam.active = true;
      DialogCam.active = false;
      LevelScreen.active = true;
      DialogScreen.active = false;
      Objective = 2;
  }

}

}

}

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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Camera Switch Error 2 Answers

Inconsistent line endings leads to loosing ability to activate/deactivate script and makes it not working 1 Answer

Event Trigger Isn't Working. 1 Answer

Menu object not responding 0 Answers

Boolean variable is never true, even if declared true or ticked in the inspector 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