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 Suraci · May 16, 2012 at 12:28 PM · tutorial

Simon Says tutorial question

Hello!

I am following a tutorial named Simon Says, http://www.youtube.com/watch?v=KSwB0N9Axp4

However I am stuck at 34-ish minutes. I have done everything the person said in the video however mine doesn't do what his does. Could anyone help me out?

(http://wtrns.fr/hdz-yb1f1aujL1c you can download my files here, I used WeTransfer).

EDIT: In the video it shows that I can now press a button, all of them should light up. however in my project it doesn't light up nor can I press on any of the 4 buttons.

Code 1 named 'SimonSays'

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 
 struct SimonLightPlate
 {
     public enum eType
     {
         INVALID_TYPE = -1,
         BLUE,
         GREEN,
         RED,
         YELLOW,
         NUM_TYPES
     }
     
     public SimonLightPlate( string plateName )
     {
         plate = GameObject.Find (plateName);
     }
 
     public GameObject plate; //The plate associated with the colors.
 }
 
 public class SimonSays : MonoBehaviour 
 {
     
     SimonLightPlate[] lightPlates = new SimonLightPlate[(int)SimonLightPlate.eType.NUM_TYPES];
     
     enum eState    
     {
         INVALID_STATE = -1,
         THINKING,
         DISPLAY_SEQUENCE,
         WAITING_FOR_USER,
         NUM_STATES
     }
 
     eState currentState = eState.INVALID_STATE;
     
     List<int> sequence = new List<int>(100); // hold the sequence
     int sequenceCount = 0; //The counter for which index of the sequence we're currently showing
     
     List<int> clickedSequence = new List<int>(100); 
         
     // Use this for initialization
     void Start () 
     {
         lightPlates[(int)SimonLightPlate.eType.BLUE]     = new SimonLightPlate("BluePlane");
         lightPlates[(int)SimonLightPlate.eType.GREEN]     = new SimonLightPlate("GreenPlane");
         lightPlates[(int)SimonLightPlate.eType.YELLOW]     = new SimonLightPlate("YellowPlane");
         lightPlates[(int)SimonLightPlate.eType.RED]     = new SimonLightPlate("RedPlane");
         
         
     }
     
     void OnLeftClickDown(SimonLightPlate.eType color)
     {
         lightPlates[(int)color].plate.renderer.enabled = true;
     }
     
     
     
     // Update is called once per frame
     void Update () 
     {
         
     }
     
     void ResetGame()
     {
         
     }
 }

Code 2 named 'ColorPlateClickHandler'

 using UnityEngine;
 using System.Collections;
 
 public class ColorPlateClickHandler : MonoBehaviour 
 {
     void OnMouseOver()
     {
         //Handle left mouse click.
         if (Input.GetMouseButtonDown(0))
         {
             SimonLightPlate.eType colorPlate = SimonLightPlate.eType.INVALID_TYPE;
             if (this.name ==         "BlueClickPlane")
             {
                 colorPlate = SimonLightPlate.eType.BLUE;
             }
             else if (this.name ==     "RedClickPlane")
             {
                 colorPlate = SimonLightPlate.eType.RED;
             }
             else if (this.name ==    "YellowClickPlane")
             {
                 colorPlate = SimonLightPlate.eType.YELLOW;
             }
             else if (this.name ==     "GreenClickPlane")
             {
                 colorPlate = SimonLightPlate.eType.GREEN;
             }
             
             this.SendMessageUpwards("OnLeftClickDown", colorPlate, SendMessageOptions.DontRequireReceiver);    
         }
         
     }
     
     void OnMouseUp()
     {
         if (Input.GetMouseButtonUp(0))
         {
             this.SendMessageUpwards("OnLeftClickUp", this.name, SendMessageOptions.DontRequireReceiver);
         }
     }
 }
Comment
Add comment · Show 27
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 AlucardJay · May 16, 2012 at 04:18 PM 1
Share

you need to provide $$anonymous$$UCH more info than that. I am all for helping noobs (as I consider myself a noob!), but even I'm not going to watch a video for 35$$anonymous$$s to see what is going on.

So, for a better chance at getting some help , try elaborating :

What is the exact problem (not just "$$anonymous$$e doesn't do what his does") ?

Where is the script you have written so far?

avatar image Suraci · May 16, 2012 at 04:31 PM 0
Share

Sorry, I was bit too focused on trying to fix it that I completely forgot about the fact that no-one can just look into my brains and see the problem I got :p.

I have edited my post and hopefully it's a bit more clear now. The problem I got is that the person in the video shows that he can click all the 4 buttons and the light on them will disappear, however when I run my version I can't click on any of the buttons plus I can't really see if they light up or not. (which he'll show around 34-ish $$anonymous$$utes.)

avatar image AlucardJay · May 16, 2012 at 04:57 PM 0
Share

at a glance I would say first check that your object names match the names you have stated in the ColorPlateClickHandler script. i.e. your yellow plate object is called YellowClickPlane , etc.

You could also check what is being sent to the OnLeftClickDown method by adding this to the ColorPlateClickHandler script :

 this.Send$$anonymous$$essageUpwards("OnLeftClickDown", colorPlate, Send$$anonymous$$essageOptions.DontRequireReceiver);
 // ** ADD THIS **
 Debug.Log("On$$anonymous$$ouseOver-$$anonymous$$ouseButton(0): colorPlate = " + colorPlate + " . This Object's name is " + this.name);

Check what appears in the console when while playing you mouse over and click on a plate. This should tell you what info is being passed to the SimonSays script.

Also , in your main script , you could add another debug in the SimonSays script to see if the method is actually being called :

 void OnLeftClickDown(SimonLightPlate.eType color)
 {
    lightPlates[(int)color].plate.renderer.enabled = true;
 Debug.Log("SimonSays : Color received = " + color);
 }

You could always watch it again and check your script and object setup is the same as the video. True story - I once repeated a tutorial just because I missed a single $$anonymous$$us sign. Also now you've done the tutorial , it should be much easier to understand what is going on, and your knowledge should improve on how to use enum, List and Send$$anonymous$$essage for yourself.

C# is not my native language, and it is way past my bedtime, so I shall check this question tomorrow to see where you are up to =]

avatar image AlucardJay · May 16, 2012 at 05:09 PM 0
Share

just saw your comment. np , it's just easier to help when all the info is ready available. Quick reflection on your comment :

can click all the 4 buttons and the light on them will disappear

don't know how the project / prefabs / materials are set up , but on mouse-click you have :

lightPlates[(int)color].plate.renderer.enabled = true;

to me that makes the material visable After clicking. I shall look later when my brain has recharged, but still try debugging and check all your na$$anonymous$$g and parenting of objects.

avatar image Suraci · May 16, 2012 at 05:11 PM 0
Share

Thanks for the quick help, seems the problem lays somewhere at

void OnLeftClickDown(SimonLightPlate.eType color) { lightPlates[(int)color].plate.renderer.enabled = true; Debug.Log("SimonSays : Color received = " + color); }

I have make it true and false but I don't get anything in my log. I am now gonna check all the names I've used and see if that needs to have some judgement. Hopefully it's just a little thing I over looked :/.

PS I have re-done this part 4 times so far ;D. I can probably type it out of my head right now o.0'

Show more comments

1 Reply

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

Answer by AlucardJay · May 17, 2012 at 06:32 PM

I have uploaded a package with my finished project. I think the most confusing part was the start when the planes are created and the textures are added. All I can suggest is check your plane placement to mine. Make sure that :

the (Red Green Blue Yellow) ClickPlane 's are just above the (RGBY) Plane 's (so they can be clicked on),

and the (RGBY) ClickPlane 's have the Transparent texture,

and the (RGBY) Plane 's have the button ON texture (lit up colour).

and the BasePlane should have the button OFF texture (all the buttons displayed as OFF)

Also when there are 2 colours displayed in a row it is hard to tell, you should add a small delay between each DisplaySequence ( I cannot help there as I don't know how to yield WaitForSeconds(0.2); in C#).

Here is the Package : http://www.alucardj.net16.net/unityanswers/Simon_Says.unitypackage

and a webpublish build : http://www.alucardj.net16.net/unityanswers/SimonSays.html

Definitely try the 3D Buzz tutorial i linked earlier , or any other 3D Buzz tutorial on their website , as they do tutorials in C#. Hope this helps =]

Comment
Add comment · Show 2 · 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 Suraci · May 17, 2012 at 06:58 PM 0
Share

Will do, and I shall now compare your work with $$anonymous$$es, hopefully I can fix my own script and laugh about it later on :P. Thanks again.

avatar image Suraci · Jun 07, 2012 at 03:33 PM 0
Share

Hey it has been a while but I got a few questions, I am currently just trying to complete some of the tutorials I've done (making a main menu, score and sound). However I can't get the score list working, any advice how to get this to work?

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

3D Platform Tutorial Problem 1 Answer

Make car game to multiplayer 1 Answer

Mecanim Tutorial Problem 2 Answers

2D Tutorial Importing problem 2 Answers

Mecanim tutorial problem 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