• 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 sereda008 · Mar 31, 2012 at 01:19 PM · itween

Script does not behave the way it should?

Hallo. I have been trying to fix the problem for some time, but I simply can not. The point is to enable the player to navigate around a 3 point room, but it just does not behave in a logical manner. Could anyone please help me with this?

I know that this is a large code, but you can ignore a large part of it, which is marked.

 // Variable declarations.
 
 var room = 1;
 var inroom = 1;
 var roomfront : Transform;
 var roomsfront : GameObject;
 var roommed : Transform;
 var roomsmed : GameObject;
 var roomback : Transform;
 var roomsback : GameObject;
 var piano : Transform;
 var walltexture: Material [];
 var walltexturetwo: Material [];
 var MainCamera : Transform;
 var MainCameraOb : GameObject;
 var MovementOfCam = 0;
 static var InWhatPlace = 0;
 var cameraStart : Vector3;
 var cameraAngles: Vector3;
 var cameraPosOne: Vector3;
 var cameraPosTwo: Vector3;
 
 function Update () 
 {
     // You can ingnore the code from here........................................................................
     // This was made some time ago for testing in an infinite map loop.
     
     if (Input.GetKeyDown("space") && inroom == 1) 
     {
         roomsfront.renderer.materials [0] = walltexture[(Random.Range(1, 4))];
         roomsmed.renderer.materials [2]= walltexturetwo[(Random.Range(1, 8))];
         roomback.position = Vector3 (-29.91534, 9.142463, (-94.81549));
         MainCamera.position = Vector3 (-25.54817, 14.8314, (-72.66501 + 7.72372));
         piano.position = Vector3 (-32.32533, 10.80438, -72.66501);
         inroom = 2;
     }
     else if (Input.GetKeyDown ("space") && inroom == 2)
     {
         roomsback.renderer.materials [0]= walltexture[(Random.Range(1, 4))];
         roomsmed.renderer.materials [2]= walltexturetwo[(Random.Range(1, 8))];
         MainCamera.position = Vector3 (-25.54817, 14.8314, (-94.81549 + 7.72372));
         piano.position = Vector3 (-32.32533, 10.80438, (-94.81549));
         roommed.position = Vector3 (-29.91534, 9.142463, (-116.96597));
         inroom = 3;
     }
     else if (Input.GetKeyDown("space") && inroom == 3)
     {
         roomsmed.renderer.materials [0]= walltexture[(Random.Range(1, 4))];
         roomsmed.renderer.materials [2]= walltexturetwo[(Random.Range(0, 8))];
         MainCamera.position = Vector3 (-25.54817, 14.8314, (-50.51353 + 7.72372));
         roomfront.position = Vector3 (-29.91534, 9.142463, -72.66501);    
         roommed.position = Vector3 (-29.91534, 9.142463, -50.51353);
         roomback.position = Vector3 (-29.91534, 9.142463, -28.36128);
         piano.position = Vector3 (-32.32533, 10.80438, -50.51353);
         inroom = 1;
     }
     // To here...................................................................................................
     //There are arrows in the scene, and they return 'Arrows.ToMoveTheCam' 1 or 2. 1 for the Keypad area and 2 for the Piano area.
     // There is also a keypad button, 'cancel', which returns ButtonPressed = 10. Otherwise these are simple key presses.
     
     if (((Input.GetKeyDown("a") && InWhatPlace == 1) || (Input.GetKeyDown("a") && InWhatPlace == 2)) || (KeyOfPad.ButtonPressed  == 10))
     {
         KeyOfPad.ButtonPressed  == 0;
         InWhatPlace = 0;
         iTween.MoveTo(MainCameraOb,Vector3(-24.07,13.57,-43.53),5);
         iTween.RotateTo(MainCameraOb, Vector3(19.01, -142.5, 0), 7);
     }
     if ((Arrows.ToMoveTheCam  == 1) || (Input.GetKeyDown("a") && InWhatPlace == 0) || (Input.GetKeyDown("a") && InWhatPlace == 2))
     {
         InWhatPlace = 1;
         iTween.MoveTo(MainCameraOb,Vector3(-28.94,12.33,-59.96),5);
         iTween.RotateTo(MainCameraOb, Vector3(0, 180, 0), 7);
         Arrows.ToMoveTheCam = 0;
     }
     if ((Arrows.ToMoveTheCam  == 2) || (Input.GetKeyDown("d") && InWhatPlace == 1) || (Input.GetKeyDown("d") && InWhatPlace == 0))
     {
         InWhatPlace = 2;
         iTween.MoveTo(MainCameraOb,Vector3(-28.40594,12.76859,-49.80258),5);
         iTween.RotateTo(MainCameraOb,Vector3(59.25, -90, 0), 6);
         Arrows.ToMoveTheCam = 0;}
     }
     // Give the error 4 times.
     //UnassignedReferenceException: The variable MainCameraOb of 'MainScript' has not been assigned.
     //You probably need to assign the MainCameraOb variable of the MainScript script in the inspector.
     //iTween.Launch (UnityEngine.GameObject target, System.Collections.Hashtable args) (at Assets/Plugins/iTween.cs:6740)
     //iTween.MoveTo (UnityEngine.GameObject target, System.Collections.Hashtable args) (at Assets/Plugins/iTween.cs:1448)
     //iTween.MoveTo (UnityEngine.GameObject target, Vector3 position, Single time) (at Assets/Plugins/iTween.cs:1347)
     //MainScript.Update () (at Assets/Other/MainScript.js:152)
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 Bunny83 · Apr 02, 2012 at 01:14 PM

"You probably need to assign the MainCameraOb variable of the MainScript script in the inspector"

...

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

iTween FadeTo() problem 1 Answer

iTween "No appropriate version" solvable? 1 Answer

iTween.ValueTo doesn't work? 0 Answers

error CS0266: Cannot implicitly convert type `UnityEngine.Component' to `iTween'. 1 Answer

Smooth Mouse Script Problems 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