Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Can't rotate object from another gameobject

Discussion in 'Editor & General Support' started by spinteractive, Sep 13, 2016.

  1. spinteractive

    spinteractive

    Joined:
    Dec 19, 2015
    Posts:
    75
    I tried everything - it's doesn't want to rotate from another object - its a collection of object btw.

    I passed in the reference..
    public GameObject Incubator;
    Incubator.transform.parent.Rotate(Vector3.up, Time.deltaTime * 50);

    I tried this..
    GameObject.Find("Incubator").transform.parent.Rotate(Vector3.up, Time.deltaTime * 50);

    I can set it active and inactive - Incubator.SetActive(false) - this works.
    It's not marked as static.
    can't rotate.. jeez

    Anybody??
     
    Last edited: Sep 13, 2016
  2. MSplitz-PsychoK

    MSplitz-PsychoK

    Joined:
    May 16, 2015
    Posts:
    1,278
    Is there an animator attached? If you have an animation with rotation, you will not be able to rotate your object as long as the animator is attached and activated.

    If that's not it, could you give more info? maybe a screenshot of the inspector with the object that won't rotate selected?
     
  3. spinteractive

    spinteractive

    Joined:
    Dec 19, 2015
    Posts:
    75
    Not using an animator. No animations on the model.
    Also, this is a HoloLens Unity project.
    Screenshot attached.

    I can rotate it from the script directly attached to the object as:
    Code (CSharp):
    1. this.transform.parent.Rotate(Vector3.up, Time.deltaTime * 50);

    but not from the script on the other object.
     

    Attached Files:

  4. Moonjump

    Moonjump

    Joined:
    Apr 15, 2010
    Posts:
    2,571
    Is it Incubator you want to rotate? Or it's parent? Your code is for rotating the parent of Incubator.
     
  5. spinteractive

    spinteractive

    Joined:
    Dec 19, 2015
    Posts:
    75
    I want to rotate the entire collection. There are 3 parent objects. The code above works. I am trying to rotate the object from a script on another object. That's what does not work. It does not work for any of the objects.

    I am now trying to rotate a different object directly in the update. This object is also passed as a reference to the script. It doesn't rotate either. Although I can set it active/inactive via same directive. Any ideas?

    TopPinkDiamond.transform.Rotate(Vector3.up, Time.deltaTime * 50);
     

    Attached Files:

    Last edited: Sep 13, 2016
  6. spinteractive

    spinteractive

    Joined:
    Dec 19, 2015
    Posts:
    75
    I've created a little test script and it works fine. It's something in my code..
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.VR.WSA.Input;
    4. using UnityEngine.Windows.Speech;
    5. using System.Collections.Generic;
    6. using System.Linq;
    7.  
    8. public class Fitbox : MonoBehaviour
    9. {
    10.     [Tooltip("The collection of holograms to show when the Fitbox is dismissed.")]
    11.     public GameObject HologramCollection;
    12.  
    13.     [Tooltip("Reposition the collection of holograms relative to where the Fitbox was dismissed.")]
    14.     public bool MoveCollectionOnDismiss = false;
    15.  
    16.     [Tooltip("The material used to render the Fitbox border.")]
    17.     public Material FitboxMaterial;
    18.  
    19.     // The offset from the Camera to the HologramCollection when
    20.     // the app starts up. This is used to place the Collection
    21.     // in the correct relative position after the Fitbox is
    22.     // dismissed.
    23.     private Vector3 collectionStartingOffsetFromCamera;
    24.  
    25.     private float Distance = 1.6f;
    26.  
    27.     private Interpolator interpolator;
    28.     private GestureRecognizer recognizer;
    29.     private bool isInitialized = false;
    30.  
    31.     GameObject testObject;
    32.  
    33.     public GameObject logo;
    34.     public GameObject TopDiamondRing;
    35.     public GameObject TopGoldBox;
    36.     public GameObject TopPlatinumBox;
    37.     public GameObject TopWhiteDiamond;
    38.     public GameObject TopPinkDiamond;
    39.     public GameObject Incubator;
    40.     public GameObject TopOrchid;
    41.     public GameObject TopTree;
    42.     public GameObject TopWoman;
    43.     public GameObject TopCouple;
    44.     public GameObject TopBloodDiamond;
    45.  
    46.     KeywordRecognizer keywordRecognizer;
    47.     Dictionary<string, System.Action> keywords = new Dictionary<string, System.Action>();
    48.  
    49.     AudioSource audioSource = null;
    50.     AudioClip tapSound = null;
    51.     AudioClip ringBoxSound = null;
    52.     AudioClip moveHoldSound = null;
    53.     AudioClip largerSound = null;
    54.     AudioClip smallerSound = null;
    55.     AudioClip pinkDiamond = null;
    56.     AudioClip incubator = null;
    57.     AudioClip treeSound = null;
    58.     AudioClip girlSound = null;
    59.     AudioClip incubatorNext = null;
    60.     AudioClip bigRing = null;
    61.     AudioClip bloodSound = null;
    62.  
    63.     bool spinInc = false;
    64.     bool spinCouple = false;
    65.     bool spinBingRing = false;
    66.     bool spinGirl = false;
    67.     bool spinTree = false;
    68.     bool spinPink = false;
    69.     bool spinBlood = false;
    70.  
    71.     private void Awake()
    72.     {
    73.  
    74.         // Add an AudioSource component and set up some defaults
    75.         audioSource = gameObject.AddComponent<AudioSource>();
    76.         audioSource.playOnAwake = false;
    77.         audioSource.spatialize = false;
    78.         audioSource.spatialBlend = 1.0f;
    79.         audioSource.dopplerLevel = 0.0f;
    80.         audioSource.rolloffMode = AudioRolloffMode.Custom;
    81.  
    82.         // Load the Sphere sounds from the Resources folder
    83.         tapSound = Resources.Load<AudioClip>("Select13");
    84.         ringBoxSound = Resources.Load<AudioClip>("SlotPrize2");
    85.         pinkDiamond = Resources.Load<AudioClip>("voice5a");
    86.         moveHoldSound = Resources.Load<AudioClip>("Select17");
    87.         smallerSound = Resources.Load<AudioClip>("Shrink2");
    88.         largerSound = Resources.Load<AudioClip>("Grow");
    89.         incubator = Resources.Load<AudioClip>("voice3a");
    90.         treeSound = Resources.Load<AudioClip>("voice7ab");
    91.         girlSound = Resources.Load<AudioClip>("IVONAa");
    92.         bigRing = Resources.Load<AudioClip>("IVONA2a");
    93.         incubatorNext = Resources.Load<AudioClip>("INC");
    94.         bloodSound = Resources.Load<AudioClip>("sociallyresponsible");
    95.  
    96.         logo.SetActive(true);
    97.         TopDiamondRing.SetActive(false);
    98.         TopPlatinumBox.SetActive(false);
    99.         TopGoldBox.SetActive(false);
    100.         TopWhiteDiamond.SetActive(false);
    101.         //TopPinkDiamond.SetActive(false);
    102.         Incubator.SetActive(false);
    103.         TopOrchid.SetActive(false);
    104.         TopTree.SetActive(false);
    105.         TopWoman.SetActive(false);
    106.         TopCouple.SetActive(false);
    107.         TopBloodDiamond.SetActive(false);
    108.  
    109.         // These are the holograms to show when the Fitbox is dismissed
    110.         if (HologramCollection)
    111.         {
    112.             collectionStartingOffsetFromCamera = HologramCollection.transform.localPosition;
    113.             HologramCollection.SetActive(false);
    114.         }
    115.  
    116.         // Set up our GestureRecognizer to listen for the SelectEvent
    117.         recognizer = new GestureRecognizer();
    118.         recognizer.TappedEvent += (source, tapCount, ray) =>
    119.         {
    120.             StartIncubator();
    121.         };
    122.         recognizer.StartCapturingGestures();
    123.     }
    124.  
    125.     ////////////////////START//////////////////////
    126.     private void Start()
    127.     {
    128.  
    129.         if (interpolator == null)
    130.         {
    131.             interpolator = gameObject.AddComponent<Interpolator>();
    132.         }
    133.  
    134.         // Screen-lock the Fitbox to match the OOBE Fitbox experience
    135.         interpolator.PositionPerSecond = 0.0f;
    136.  
    137.         GameObject.Find("gSpeechManager").GetComponent<SpeechManager>().enabled = false;
    138.         GameObject.Find("gGestureManager").GetComponent<GazeGestureManager>().enabled = false;
    139.  
    140.         testObject = GameObject.FindGameObjectWithTag("TEST");
    141.  
    142.  
    143.  
    144.     }
    145.  
    146.     ////////////////////UPDATE//////////////////////
    147.     void update()
    148.     {
    149.         if (spinInc)
    150.         {
    151.            
    152.         }
    153.         //TopPinkDiamond.transform.Rotate(Vector3.up, Time.deltaTime * 50);
    154.         testObject.transform.Rotate(Vector3.up, Time.deltaTime * 50);
    155.     }
    156.  
    157.     ////////////////////INCUBATOR//////////////////////
    158.     private void StartIncubator()
    159.     {
    160.         //Dismiss logo
    161.         logo.SetActive(false);
    162.  
    163.         //Turn on incubaotr
    164.         Incubator.SetActive(true);
    165.         spinInc = true;
    166.  
    167.         //Create keywords for keyword recognizer
    168.         keywords.Add("Tell Me", () =>
    169.         {
    170.             if (spinInc)
    171.             {
    172.                 audioSource.clip = incubator;
    173.                 keywordRecognizer.Stop();
    174.             }
    175.             else if (spinBingRing)
    176.             {
    177.                 audioSource.clip = bigRing;
    178.                 spinBingRing = false;
    179.                 keywordRecognizer.Stop();
    180.             }
    181.             else if (spinGirl)
    182.             {
    183.                 audioSource.clip = girlSound;
    184.                 spinGirl = false;
    185.                 keywordRecognizer.Stop();
    186.             }
    187.             else if (spinTree)
    188.             {
    189.                 audioSource.clip = treeSound;
    190.                 spinTree = false;
    191.                 keywordRecognizer.Stop();
    192.             }
    193.             else if (spinPink)
    194.             {
    195.                 audioSource.clip = pinkDiamond;
    196.                 spinPink = false;
    197.                 keywordRecognizer.Stop();
    198.             }
    199.             else if (spinBlood)
    200.             {
    201.                 audioSource.clip = bloodSound;
    202.                 spinBlood = false;
    203.                 keywordRecognizer.Stop();
    204.             }
    205.             audioSource.Play();
    206.         });
    207.         keywordRecognizer = new KeywordRecognizer(keywords.Keys.ToArray());
    208.         keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
    209.         keywordRecognizer.Start();
    210.  
    211.         // Set up our GestureRecognizer to listen for the SelectEvent
    212.         recognizer = new GestureRecognizer();
    213.         recognizer.TappedEvent += (source, tapCount, ray) =>
    214.         {
    215.             //Go to next
    216.             StartCouple();    
    217.         };
    218.         recognizer.StartCapturingGestures();
    219.     }
    220.  
    221.     ////////////////////SPEECH CALLBACK//////////////////////
    222.     private void KeywordRecognizer_OnPhraseRecognized(PhraseRecognizedEventArgs args)
    223.     {
    224.         System.Action keywordAction;
    225.         // if the keyword recognized is in our dictionary, call that Action.
    226.         if (keywords.TryGetValue(args.text, out keywordAction))
    227.         {
    228.             keywordAction.Invoke();
    229.         }
    230.     }
    231.  
    232.     ////////////////////COUPLE//////////////////////
    233.     private void StartCouple()
    234.     {
    235.         TopCouple.SetActive(true);
    236.         spinInc = false;
    237.  
    238.         // Set up our GestureRecognizer to listen for the SelectEvent
    239.         recognizer = new GestureRecognizer();
    240.         recognizer.TappedEvent += (source, tapCount, ray) =>
    241.         {
    242.             StartLargeRing();
    243.         };
    244.         recognizer.StartCapturingGestures();
    245.     }
    246.  
    247.     ////////////////////LARGE RING//////////////////////
    248.     private void StartLargeRing()
    249.     {
    250.         //Turn on/off
    251.         keywordRecognizer.Start();
    252.         TopDiamondRing.SetActive(true);
    253.         spinBingRing = true;
    254.         spinInc = false;
    255.  
    256.         // Set up our GestureRecognizer to listen for the SelectEvent
    257.         recognizer = new GestureRecognizer();
    258.         recognizer.TappedEvent += (source, tapCount, ray) =>
    259.         {
    260.             //Go to next
    261.             StartGirl();
    262.         };
    263.         recognizer.StartCapturingGestures();
    264.     }
    265.  
    266.     ////////////////////GIRL//////////////////////
    267.     private void StartGirl()
    268.     {
    269.         //Turn on/off
    270.         keywordRecognizer.Start();
    271.         TopWoman.SetActive(true);
    272.         spinGirl = true;
    273.         spinBingRing = false;
    274.         spinInc = false;
    275.  
    276.         // Set up our GestureRecognizer to listen for the SelectEvent
    277.         recognizer = new GestureRecognizer();
    278.         recognizer.TappedEvent += (source, tapCount, ray) =>
    279.         {
    280.             //Go to next
    281.             StartTree();
    282.         };
    283.         recognizer.StartCapturingGestures();
    284.     }
    285.  
    286.     ////////////////////TREE//////////////////////
    287.     private void StartTree()
    288.     {
    289.         //Turn on/off
    290.         keywordRecognizer.Start();
    291.         TopTree.SetActive(true);
    292.         spinTree = true;
    293.         spinGirl = false;
    294.         spinBingRing = false;
    295.         spinInc = false;
    296.  
    297.         // Set up our GestureRecognizer to listen for the SelectEvent
    298.         recognizer = new GestureRecognizer();
    299.         recognizer.TappedEvent += (source, tapCount, ray) =>
    300.         {
    301.             //Go to next
    302.             StartPink();
    303.         };
    304.         recognizer.StartCapturingGestures();
    305.     }
    306.  
    307.     ////////////////////PINK DIAMOND//////////////////////
    308.     private void StartPink()
    309.     {
    310.         //Turn on/off
    311.         keywordRecognizer.Start();
    312.         TopPinkDiamond.SetActive(true);
    313.         TopWhiteDiamond.SetActive(true);
    314.         TopOrchid.SetActive(true);
    315.         spinPink = true;
    316.         spinTree = false;
    317.         spinGirl = false;
    318.         spinBingRing = false;
    319.         spinInc = false;
    320.  
    321.         // Set up our GestureRecognizer to listen for the SelectEvent
    322.         recognizer = new GestureRecognizer();
    323.         recognizer.TappedEvent += (source, tapCount, ray) =>
    324.         {
    325.             //Go to next
    326.             StartBlood();
    327.         };
    328.         recognizer.StartCapturingGestures();
    329.     }
    330.  
    331.     ////////////////////BLOODY//////////////////////
    332.     private void StartBlood()
    333.     {
    334.         //Turn on/off
    335.         keywordRecognizer.Start();
    336.         TopBloodDiamond.SetActive(true);
    337.         spinBlood = true;
    338.         spinPink = false;
    339.         spinTree = false;
    340.         spinGirl = false;
    341.         spinBingRing = false;
    342.         spinInc = false;
    343.  
    344.         // Set up our GestureRecognizer to listen for the SelectEvent
    345.         recognizer = new GestureRecognizer();
    346.         recognizer.TappedEvent += (source, tapCount, ray) =>
    347.         {
    348.             //Go to next
    349.             StartBoxes();
    350.         };
    351.         recognizer.StartCapturingGestures();
    352.     }
    353.  
    354.     ////////////////////RING BOXES//////////////////////
    355.     private void StartBoxes()
    356.     {
    357.         //Start
    358.         TopGoldBox.SetActive(true);
    359.         TopPlatinumBox.SetActive(true);
    360.  
    361.         //Close and dispose
    362.         recognizer.CancelGestures();
    363.         recognizer.StopCapturingGestures();
    364.         recognizer.Dispose();
    365.         keywordRecognizer.Stop();
    366.         keywordRecognizer.Dispose();
    367.  
    368.         //activate global speech and gesture
    369.         GameObject.Find("gSpeechManager").GetComponent<SpeechManager>().enabled = true;
    370.         GameObject.Find("gGestureManager").GetComponent<GazeGestureManager>().enabled = true;
    371.     }
    372.  
    373.     private void InitializeComponents()
    374.     {
    375.         // Return early if we've already been initialized...
    376.         if (isInitialized || Camera.main == null)
    377.         {
    378.             return;
    379.         }
    380.  
    381.         // Calculate Hologram Dimensions and Positions based on RedLine drawing
    382.         const int drawingPixelWidth = 1440;
    383.         const int drawingPixelHeight = 818;
    384.         const int drawingBoxLeftEdgeScreen = 240;
    385.         const int drawingBoxBottomEdgeScreen = 139;
    386.         const int drawingBoxWidthScreen = 960;
    387.         const int drawingBoxHeightScreen = 540;
    388.         const int drawingQuadWidthScreen = 8;
    389.         const int drawingQuadHeightScreen = 8;
    390.         // Calculate a ratio between the actual screen dimensions and those of the RedLine drawing
    391.         var xRatio = (float)Camera.main.pixelWidth / (float)drawingPixelWidth;
    392.         var yRatio = (float)Camera.main.pixelHeight / (float)drawingPixelHeight;
    393.         // Factor the real dimensions in screen space
    394.         var realBoxLeftEdgeScreen = drawingBoxLeftEdgeScreen * xRatio;
    395.         var realBoxBottomEdgeScreen = drawingBoxBottomEdgeScreen * yRatio;
    396.         var realBoxWidthScreen = drawingBoxWidthScreen * xRatio;
    397.         var realBoxHeightScreen = drawingBoxHeightScreen * yRatio;
    398.         var realQuadWidthScreen = drawingQuadWidthScreen * xRatio;
    399.         var realQuadHeightScreen = drawingQuadHeightScreen * yRatio;
    400.         // Calculate the real width of the top/bottom (horizontal) quads
    401.         var hQuadLeftEdgeScreen = new Vector3(realBoxLeftEdgeScreen, realBoxBottomEdgeScreen + (realQuadHeightScreen / 2.0f), Distance);
    402.         var hQuadLeftEdge = Camera.main.ScreenToWorldPoint(hQuadLeftEdgeScreen);
    403.         var hQuadRightEdgeScreen = new Vector3(realBoxLeftEdgeScreen + realBoxWidthScreen, hQuadLeftEdgeScreen.y, Distance);
    404.         var hQuadRightEdge = Camera.main.ScreenToWorldPoint(hQuadRightEdgeScreen);
    405.         var hQuadWid = Vector3.Distance(hQuadRightEdge, hQuadLeftEdge);
    406.         // Calculate the real height of the top/bottom (horizontal) quads
    407.         var hQuadBottomEdgeScreen = new Vector3(0, hQuadLeftEdge.y, Distance);
    408.         var hQuadBottomEdge = Camera.main.ScreenToWorldPoint(hQuadBottomEdgeScreen);
    409.         var hQuadTopEdgeScreen = new Vector3(0, hQuadBottomEdgeScreen.y + realQuadHeightScreen, Distance);
    410.         var hQuadTopEdge = Camera.main.ScreenToWorldPoint(hQuadTopEdgeScreen);
    411.         var hQuadHgt = Vector3.Distance(hQuadTopEdge, hQuadBottomEdge);
    412.         // Calculate the real height of the left/right (vertical) quads
    413.         var vQuadBottomEdgeScreen = new Vector3(realBoxLeftEdgeScreen + (realQuadWidthScreen / 2.0f), realBoxBottomEdgeScreen, Distance);
    414.         var vQuadBottomEdge = Camera.main.ScreenToWorldPoint(vQuadBottomEdgeScreen);
    415.         var vQuadTopEdgeScreen = new Vector3(vQuadBottomEdgeScreen.x, realBoxBottomEdgeScreen + realBoxHeightScreen, Distance);
    416.         var vQuadTopEdge = Camera.main.ScreenToWorldPoint(vQuadTopEdgeScreen);
    417.         var vQuadHgt = Vector3.Distance(vQuadTopEdge, vQuadBottomEdge);
    418.         // Calculate the real width of the left/right quads...
    419.         // ...just use the height of the horizontal quad for the width of the vertical quad
    420.         var vQuadWid = hQuadHgt;
    421.  
    422.         // Create the Quads for our FitBox
    423.         /*  leftQuad*/
    424.         //CreateFitboxQuad(transform, (-hQuadWid / 2.0f) + (vQuadWid / 2.0f), 0f, vQuadWid, vQuadHgt);
    425.         /* rightQuad*/
    426.         //CreateFitboxQuad(transform, (hQuadWid / 2.0f) - (vQuadWid / 2.0f), 0f, vQuadWid, vQuadHgt);
    427.         /*bottomQuad*/
    428.         //CreateFitboxQuad(transform, 0f, (vQuadHgt / 2.0f) - (hQuadHgt / 2.0f), hQuadWid, hQuadHgt);
    429.         /*   topQuad*/
    430.         //CreateFitboxQuad(transform, 0f, (-vQuadHgt / 2.0f) + (hQuadHgt / 2.0f), hQuadWid, hQuadHgt);
    431.  
    432.         isInitialized = true;
    433.     }
    434.  
    435.     private void CreateFitboxQuad(Transform parent, float xPos, float yPos, float width, float height)
    436.     {
    437.         var quad = GameObject.CreatePrimitive(PrimitiveType.Quad);
    438.         quad.transform.parent = parent;
    439.         quad.transform.localPosition = new Vector3(xPos, yPos, 0);
    440.         quad.transform.localScale = new Vector3(width, height, quad.transform.localScale.z);
    441.         quad.transform.localRotation = Quaternion.Euler(0f, 180f, 0f);
    442.         quad.GetComponent<MeshRenderer>().material = FitboxMaterial;
    443.     }
    444.  
    445.     int foo = 0;
    446.     private void LateUpdate()
    447.     {
    448.         foo++;
    449.         if (foo < 2) return;
    450.         InitializeComponents();
    451.  
    452.         Transform cameraTransform = Camera.main.transform;
    453.  
    454.         interpolator.SetTargetPosition(cameraTransform.position + (cameraTransform.forward * Distance));
    455.         interpolator.SetTargetRotation(Quaternion.LookRotation(-cameraTransform.forward, -cameraTransform.up));
    456.     }
    457.  
    458.  
    459. }
    460.  
     
  7. spinteractive

    spinteractive

    Joined:
    Dec 19, 2015
    Posts:
    75
    I commented everything out on my script except the 3 lines to reference the object and rotate it. It still does NOT rotate.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.VR.WSA.Input;
    4. using UnityEngine.Windows.Speech;
    5. using System.Collections.Generic;
    6. using System.Linq;
    7.  
    8. public class StartApp : MonoBehaviour
    9. {
    10.  
    11.     //public GameObject HologramCollection;
    12.    // public bool MoveCollectionOnDismiss = false;
    13.    // public Material FitboxMaterial;
    14.  
    15.     // The offset from the Camera to the HologramCollection when
    16.     // the app starts up. This is used to place the Collection
    17.     // in the correct relative position after the Fitbox is
    18.     // dismissed.
    19.    // private Vector3 collectionStartingOffsetFromCamera;
    20.  
    21.    // private float Distance = 1.6f;
    22.  
    23.    // private Interpolator interpolator;
    24.    // private GestureRecognizer recognizer;
    25.   //  private bool isInitialized = false;
    26.  
    27.     GameObject testObject;
    28.  
    29.     /*
    30.     public GameObject logo;
    31.     public GameObject TopDiamondRing;
    32.     public GameObject TopGoldBox;
    33.     public GameObject TopPlatinumBox;
    34.     public GameObject TopWhiteDiamond;
    35.     public GameObject TopPinkDiamond;
    36.     public GameObject Incubator;
    37.     public GameObject TopOrchid;
    38.     public GameObject TopTree;
    39.     public GameObject TopWoman;
    40.     public GameObject TopCouple;
    41.     public GameObject TopBloodDiamond;
    42.  
    43.     KeywordRecognizer keywordRecognizer;
    44.     Dictionary<string, System.Action> keywords = new Dictionary<string, System.Action>();
    45.  
    46.     AudioSource audioSource = null;
    47.     AudioClip tapSound = null;
    48.     AudioClip ringBoxSound = null;
    49.     AudioClip moveHoldSound = null;
    50.     AudioClip largerSound = null;
    51.     AudioClip smallerSound = null;
    52.     AudioClip pinkDiamond = null;
    53.     AudioClip incubator = null;
    54.     AudioClip treeSound = null;
    55.     AudioClip girlSound = null;
    56.     AudioClip incubatorNext = null;
    57.     AudioClip bigRing = null;
    58.     AudioClip bloodSound = null;
    59.     */
    60.  
    61.         /*
    62.     bool spinInc = false;
    63.     bool spinCouple = false;
    64.     bool spinBingRing = false;
    65.     bool spinGirl = false;
    66.     bool spinTree = false;
    67.     bool spinPink = false;
    68.     bool spinBlood = false;
    69.     */
    70.  
    71.     private void Awake()
    72.     {
    73.         /*
    74.         // Add an AudioSource component and set up some defaults
    75.         audioSource = gameObject.AddComponent<AudioSource>();
    76.         audioSource.playOnAwake = false;
    77.         audioSource.spatialize = false;
    78.         audioSource.spatialBlend = 1.0f;
    79.         audioSource.dopplerLevel = 0.0f;
    80.         audioSource.rolloffMode = AudioRolloffMode.Custom;
    81.  
    82.         // Load the Sphere sounds from the Resources folder
    83.         tapSound = Resources.Load<AudioClip>("Select13");
    84.         ringBoxSound = Resources.Load<AudioClip>("SlotPrize2");
    85.         pinkDiamond = Resources.Load<AudioClip>("voice5a");
    86.         moveHoldSound = Resources.Load<AudioClip>("Select17");
    87.         smallerSound = Resources.Load<AudioClip>("Shrink2");
    88.         largerSound = Resources.Load<AudioClip>("Grow");
    89.         incubator = Resources.Load<AudioClip>("voice3a");
    90.         treeSound = Resources.Load<AudioClip>("voice7ab");
    91.         girlSound = Resources.Load<AudioClip>("IVONAa");
    92.         bigRing = Resources.Load<AudioClip>("IVONA2a");
    93.         incubatorNext = Resources.Load<AudioClip>("INC");
    94.         bloodSound = Resources.Load<AudioClip>("sociallyresponsible");
    95.  
    96.         logo.SetActive(true);
    97.         TopDiamondRing.SetActive(false);
    98.         TopPlatinumBox.SetActive(false);
    99.         TopGoldBox.SetActive(false);
    100.         TopWhiteDiamond.SetActive(false);
    101.         //TopPinkDiamond.SetActive(false);
    102.         Incubator.SetActive(false);
    103.         TopOrchid.SetActive(false);
    104.         TopTree.SetActive(false);
    105.         TopWoman.SetActive(false);
    106.         TopCouple.SetActive(false);
    107.         TopBloodDiamond.SetActive(false);
    108.  
    109.         // These are the holograms to show when the Fitbox is dismissed
    110.         if (HologramCollection)
    111.         {
    112.             collectionStartingOffsetFromCamera = HologramCollection.transform.localPosition;
    113.             HologramCollection.SetActive(false);
    114.         }
    115.  
    116.         // Set up our GestureRecognizer to listen for the SelectEvent
    117.         recognizer = new GestureRecognizer();
    118.         recognizer.TappedEvent += (source, tapCount, ray) =>
    119.         {
    120.             StartIncubator();
    121.         };
    122.         recognizer.StartCapturingGestures();
    123.         */
    124.     }
    125.  
    126.     ////////////////////START//////////////////////
    127.     private void Start()
    128.     {
    129.         /*
    130.         if (interpolator == null)
    131.         {
    132.             interpolator = gameObject.AddComponent<Interpolator>();
    133.         }
    134.  
    135.         // Screen-lock the Fitbox to match the OOBE Fitbox experience
    136.         interpolator.PositionPerSecond = 0.0f;
    137.  
    138.        GameObject.Find("gSpeechManager").GetComponent<SpeechManager>().enabled = false;
    139.        GameObject.Find("gGestureManager").GetComponent<GazeGestureManager>().enabled = false;
    140. */
    141.         testObject = GameObject.FindGameObjectWithTag("TEST");
    142.  
    143.  
    144.  
    145.     }
    146.  
    147.     ////////////////////UPDATE//////////////////////
    148.     void update()
    149.     {
    150.         //TopPinkDiamond.transform.Rotate(Vector3.up, Time.deltaTime * 50);
    151.         testObject.transform.Rotate(Vector3.up, Time.deltaTime * 50);
    152.     }
    153.  
    154.     ////////////////////INCUBATOR//////////////////////
    155.     private void StartIncubator()
    156.     {
    157.         /*
    158.         //Dismiss logo
    159.         logo.SetActive(false);
    160.  
    161.         //Turn on incubaotr
    162.         Incubator.SetActive(true);
    163.         spinInc = true;
    164.  
    165.         //Create keywords for keyword recognizer
    166.         keywords.Add("Tell Me", () =>
    167.         {
    168.             if (spinInc)
    169.             {
    170.                 audioSource.clip = incubator;
    171.                 keywordRecognizer.Stop();
    172.             }
    173.             else if (spinBingRing)
    174.             {
    175.                 audioSource.clip = bigRing;
    176.                 spinBingRing = false;
    177.                 keywordRecognizer.Stop();
    178.             }
    179.             else if (spinGirl)
    180.             {
    181.                 audioSource.clip = girlSound;
    182.                 spinGirl = false;
    183.                 keywordRecognizer.Stop();
    184.             }
    185.             else if (spinTree)
    186.             {
    187.                 audioSource.clip = treeSound;
    188.                 spinTree = false;
    189.                 keywordRecognizer.Stop();
    190.             }
    191.             else if (spinPink)
    192.             {
    193.                 audioSource.clip = pinkDiamond;
    194.                 spinPink = false;
    195.                 keywordRecognizer.Stop();
    196.             }
    197.             else if (spinBlood)
    198.             {
    199.                 audioSource.clip = bloodSound;
    200.                 spinBlood = false;
    201.                 keywordRecognizer.Stop();
    202.             }
    203.             audioSource.Play();
    204.         });
    205.         keywordRecognizer = new KeywordRecognizer(keywords.Keys.ToArray());
    206.         keywordRecognizer.OnPhraseRecognized += KeywordRecognizer_OnPhraseRecognized;
    207.         keywordRecognizer.Start();
    208.  
    209.         // Set up our GestureRecognizer to listen for the SelectEvent
    210.         recognizer = new GestureRecognizer();
    211.         recognizer.TappedEvent += (source, tapCount, ray) =>
    212.         {
    213.             //Go to next
    214.             StartCouple();
    215.         };
    216.         recognizer.StartCapturingGestures();
    217.         */
    218.     }
    219.  
    220.     /*
    221.     ////////////////////SPEECH CALLBACK//////////////////////
    222.     private void KeywordRecognizer_OnPhraseRecognized(PhraseRecognizedEventArgs args)
    223.     {
    224.         System.Action keywordAction;
    225.         // if the keyword recognized is in our dictionary, call that Action.
    226.         if (keywords.TryGetValue(args.text, out keywordAction))
    227.         {
    228.             keywordAction.Invoke();
    229.         }
    230.     }
    231.     */
    232.  
    233.     ////////////////////COUPLE//////////////////////
    234.     private void StartCouple()
    235.     {
    236.    //     TopCouple.SetActive(true);
    237.         //spinInc = false;
    238.  
    239.         // Set up our GestureRecognizer to listen for the SelectEvent
    240.  
    241.     }
    242.  
    243.     ////////////////////LARGE RING//////////////////////
    244.     private void StartLargeRing()
    245.     {
    246.         //Turn on/off
    247.   //      keywordRecognizer.Start();
    248.   //      TopDiamondRing.SetActive(true);
    249.         //spinBingRing = true;
    250.         //spinInc = false;
    251.  
    252.         // Set up our GestureRecognizer to listen for the SelectEvent
    253.  
    254.     }
    255.  
    256.     ////////////////////GIRL//////////////////////
    257.     private void StartGirl()
    258.     {
    259.         //Turn on/off
    260. //       keywordRecognizer.Start();
    261. //       TopWoman.SetActive(true);
    262.         //spinGirl = true;
    263.        // spinBingRing = false;
    264.        // spinInc = false;
    265.  
    266.         // Set up our GestureRecognizer to listen for the SelectEvent
    267.  
    268.     }
    269.  
    270.     ////////////////////TREE//////////////////////
    271.     private void StartTree()
    272.     {
    273.         //Turn on/off
    274. //       keywordRecognizer.Start();
    275. //       TopTree.SetActive(true);
    276.        // spinTree = true;
    277.       //  spinGirl = false;
    278.       //  spinBingRing = false;
    279.       //  spinInc = false;
    280.  
    281.         // Set up our GestureRecognizer to listen for the SelectEvent
    282.  
    283.     }
    284.  
    285.     ////////////////////PINK DIAMOND//////////////////////
    286.     private void StartPink()
    287.     {
    288.         //Turn on/off
    289. //       keywordRecognizer.Start();
    290.   //      TopPinkDiamond.SetActive(true);
    291.   //      TopWhiteDiamond.SetActive(true);
    292. //       TopOrchid.SetActive(true);
    293.      //   spinPink = true;
    294.      //   spinTree = false;
    295.      //   spinGirl = false;
    296.      //   spinBingRing = false;
    297.      //   spinInc = false;
    298.  
    299.         // Set up our GestureRecognizer to listen for the SelectEvent
    300.  
    301.     }
    302.  
    303.     ////////////////////BLOODY//////////////////////
    304.     private void StartBlood()
    305.     {
    306.         //Turn on/off
    307.   //      keywordRecognizer.Start();
    308. //       TopBloodDiamond.SetActive(true);
    309. /*
    310.         spinBlood = true;
    311.         spinPink = false;
    312.         spinTree = false;
    313.         spinGirl = false;
    314.         spinBingRing = false;
    315.         spinInc = false;
    316.         */
    317.         // Set up our GestureRecognizer to listen for the SelectEvent
    318.  
    319.     }
    320.  
    321.     ////////////////////RING BOXES//////////////////////
    322.     private void StartBoxes()
    323.     {
    324.         //Start
    325.   //      TopGoldBox.SetActive(true);
    326.   //      TopPlatinumBox.SetActive(true);
    327.  
    328.         //Close and dispose
    329.    //     recognizer.CancelGestures();
    330.    //     recognizer.StopCapturingGestures();
    331.    //     recognizer.Dispose();
    332.   //      keywordRecognizer.Stop();
    333.   //      keywordRecognizer.Dispose();
    334.  
    335.         //activate global speech and gesture
    336.       //  GameObject.Find("gSpeechManager").GetComponent<SpeechManager>().enabled = true;
    337.       //  GameObject.Find("gGestureManager").GetComponent<GazeGestureManager>().enabled = true;
    338.     }
    339.  
    340.     /*
    341.     private void InitializeComponents()
    342.     {
    343.         // Return early if we've already been initialized...
    344.         if (isInitialized || Camera.main == null)
    345.         {
    346.             return;
    347.         }
    348.  
    349.         // Calculate Hologram Dimensions and Positions based on RedLine drawing
    350.         const int drawingPixelWidth = 1440;
    351.         const int drawingPixelHeight = 818;
    352.         const int drawingBoxLeftEdgeScreen = 240;
    353.         const int drawingBoxBottomEdgeScreen = 139;
    354.         const int drawingBoxWidthScreen = 960;
    355.         const int drawingBoxHeightScreen = 540;
    356.         const int drawingQuadWidthScreen = 8;
    357.         const int drawingQuadHeightScreen = 8;
    358.         // Calculate a ratio between the actual screen dimensions and those of the RedLine drawing
    359.         var xRatio = (float)Camera.main.pixelWidth / (float)drawingPixelWidth;
    360.         var yRatio = (float)Camera.main.pixelHeight / (float)drawingPixelHeight;
    361.         // Factor the real dimensions in screen space
    362.         var realBoxLeftEdgeScreen = drawingBoxLeftEdgeScreen * xRatio;
    363.         var realBoxBottomEdgeScreen = drawingBoxBottomEdgeScreen * yRatio;
    364.         var realBoxWidthScreen = drawingBoxWidthScreen * xRatio;
    365.         var realBoxHeightScreen = drawingBoxHeightScreen * yRatio;
    366.         var realQuadWidthScreen = drawingQuadWidthScreen * xRatio;
    367.         var realQuadHeightScreen = drawingQuadHeightScreen * yRatio;
    368.         // Calculate the real width of the top/bottom (horizontal) quads
    369.         var hQuadLeftEdgeScreen = new Vector3(realBoxLeftEdgeScreen, realBoxBottomEdgeScreen + (realQuadHeightScreen / 2.0f), Distance);
    370.         var hQuadLeftEdge = Camera.main.ScreenToWorldPoint(hQuadLeftEdgeScreen);
    371.         var hQuadRightEdgeScreen = new Vector3(realBoxLeftEdgeScreen + realBoxWidthScreen, hQuadLeftEdgeScreen.y, Distance);
    372.         var hQuadRightEdge = Camera.main.ScreenToWorldPoint(hQuadRightEdgeScreen);
    373.         var hQuadWid = Vector3.Distance(hQuadRightEdge, hQuadLeftEdge);
    374.         // Calculate the real height of the top/bottom (horizontal) quads
    375.         var hQuadBottomEdgeScreen = new Vector3(0, hQuadLeftEdge.y, Distance);
    376.         var hQuadBottomEdge = Camera.main.ScreenToWorldPoint(hQuadBottomEdgeScreen);
    377.         var hQuadTopEdgeScreen = new Vector3(0, hQuadBottomEdgeScreen.y + realQuadHeightScreen, Distance);
    378.         var hQuadTopEdge = Camera.main.ScreenToWorldPoint(hQuadTopEdgeScreen);
    379.         var hQuadHgt = Vector3.Distance(hQuadTopEdge, hQuadBottomEdge);
    380.         // Calculate the real height of the left/right (vertical) quads
    381.         var vQuadBottomEdgeScreen = new Vector3(realBoxLeftEdgeScreen + (realQuadWidthScreen / 2.0f), realBoxBottomEdgeScreen, Distance);
    382.         var vQuadBottomEdge = Camera.main.ScreenToWorldPoint(vQuadBottomEdgeScreen);
    383.         var vQuadTopEdgeScreen = new Vector3(vQuadBottomEdgeScreen.x, realBoxBottomEdgeScreen + realBoxHeightScreen, Distance);
    384.         var vQuadTopEdge = Camera.main.ScreenToWorldPoint(vQuadTopEdgeScreen);
    385.         var vQuadHgt = Vector3.Distance(vQuadTopEdge, vQuadBottomEdge);
    386.         // Calculate the real width of the left/right quads...
    387.         // ...just use the height of the horizontal quad for the width of the vertical quad
    388.         var vQuadWid = hQuadHgt;
    389.  
    390.         // Create the Quads for our FitBox
    391.         /*  leftQuad*/
    392.         //CreateFitboxQuad(transform, (-hQuadWid / 2.0f) + (vQuadWid / 2.0f), 0f, vQuadWid, vQuadHgt);
    393.         /* rightQuad*/
    394.         //CreateFitboxQuad(transform, (hQuadWid / 2.0f) - (vQuadWid / 2.0f), 0f, vQuadWid, vQuadHgt);
    395.         /*bottomQuad*/
    396.         //CreateFitboxQuad(transform, 0f, (vQuadHgt / 2.0f) - (hQuadHgt / 2.0f), hQuadWid, hQuadHgt);
    397.         /*   topQuad*/
    398.         //CreateFitboxQuad(transform, 0f, (-vQuadHgt / 2.0f) + (hQuadHgt / 2.0f), hQuadWid, hQuadHgt);
    399.  
    400.         //isInitialized = true;
    401.   //  }
    402.  
    403. /*
    404.     private void CreateFitboxQuad(Transform parent, float xPos, float yPos, float width, float height)
    405.     {
    406.         var quad = GameObject.CreatePrimitive(PrimitiveType.Quad);
    407.         quad.transform.parent = parent;
    408.         quad.transform.localPosition = new Vector3(xPos, yPos, 0);
    409.         quad.transform.localScale = new Vector3(width, height, quad.transform.localScale.z);
    410.         quad.transform.localRotation = Quaternion.Euler(0f, 180f, 0f);
    411.         quad.GetComponent<MeshRenderer>().material = FitboxMaterial;
    412.     }
    413.  
    414.     int foo = 0;
    415.     private void LateUpdate()
    416.     {
    417.         foo++;
    418.         if (foo < 2) return;
    419.         InitializeComponents();
    420.  
    421.         Transform cameraTransform = Camera.main.transform;
    422.  
    423.         interpolator.SetTargetPosition(cameraTransform.position + (cameraTransform.forward * Distance));
    424.         interpolator.SetTargetRotation(Quaternion.LookRotation(-cameraTransform.forward, -cameraTransform.up));
    425.     }
    426.     */
    427.  
    428. }
    429.  
    This is my test script that works... they are the same..

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class testScript : MonoBehaviour {
    5.     GameObject testObject;
    6.  
    7.     // Use this for initialization
    8.     void Start () {
    9.         testObject = GameObject.FindGameObjectWithTag("TEST");
    10.     }
    11.  
    12.     // Update is called once per frame
    13.     void Update () {
    14.         testObject.transform.Rotate(Vector3.up, Time.deltaTime * 50);
    15.     }
    16. }
    17.  
    WHAT IS GOING ON??????
     
  8. mikael_juhala

    mikael_juhala

    Joined:
    Mar 9, 2015
    Posts:
    247
    Your update method is in lowercase ("void update").

    EDIT: Ah, I notice you found the same error in another thread. :)