• 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 Grey_Wolf9 · Aug 15, 2018 at 03:23 PM · componentslevel-design

Adding different number of components to each level

Hello all noob here

So currently my game looks like the picture I have attached. Basically different levels of force exerted on a sensor respond to different colours and textures(faces) on a sphere. I currently have four different levels, so four different colours, faces and times basically. What I want to do is change the amount of spheres in each level. And when the sensor is pressed each sphere changes from a plain white sphere to the face and colour of that level. So for example, in level 1 I want 4 spheres. And if the sensor is pressed once, 1 sphere will change to an angry red face and stay like that. Then when the sensor is pressed again, the next face changes to an angry red face and so forth. Then in the second level, I will have 3 spheres. When the sensor is pressed once, one sphere will change to a happy yellow face. When the sensor is pressed twice, another sphere will change to a happy yellow face and so forth. How would I go about doing this? I am currently feeling overwhelmed by the coding that this might entail. I have also attached the code to one of my levels so far:`

 ![using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using System.IO.Ports;
 public class Arduino3 : MonoBehaviour
 {
 
     SerialPort sp = new SerialPort("\\\\.\\COM5", 9600);// Com port and the baud rate of the arduino
     Material m_Material;
     GameObject Sphere;
 
 
 
     void Awake()
     {
         Sphere = GameObject.FindWithTag("Player");
         m_Material = GameObject.FindWithTag("Player").GetComponent<Renderer>().material;
     }
     void Start()
     {
         if (!sp.IsOpen)
         { // If the erial port is not open 
             sp.Open(); // Open 
         }
         sp.ReadTimeout = 250; // Timeout for reading 
     }
 
     // Update is called once per frame
     void Update()
     {
         if (sp.IsOpen)
         { // Check to see if the serial port is open 
             try
             {
 
                 string portreading = sp.ReadLine(); // get the string output of the serial port 
                 float amount = int.Parse(portreading);
 
 
                 if ((amount > 201f))
                 {
                     m_Material.color = Color.yellow;
                     Renderer _rend = Sphere.GetComponent<Renderer>();
                     Sphere.GetComponent<Renderer>().material = _rend.material;
                     _rend.material.mainTexture = Resources.Load("face3") as Texture;
 
                  }
                 else
                 {
                     m_Material.color = Color.white;
                 }
 
             }
             catch (System.Exception)
             {
 
             }
 
         }
 
     }
 }
 
 
 `][1]


[1]: /storage/temp/122787-freeze.png

freeze.png (146.3 kB)
Comment
Add comment · Show 1
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 RShields · Aug 15, 2018 at 02:08 PM 0
Share

You're probably better off learning core concepts of program$$anonymous$$g than asking here since you shouldn't ever expect someone to code a whole system for you.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by tormentoarmagedoom · Aug 15, 2018 at 02:32 PM

Good day.

Are you asking to develop for you a full code for your propuses?

Good bye.

Comment
Add comment · Show 4 · 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 RShields · Aug 15, 2018 at 03:36 PM 0
Share

Responses like this should go in the Comments.

avatar image Grey_Wolf9 · Aug 15, 2018 at 03:52 PM 0
Share

not really, i would like pointers as to how i can go about this

avatar image RShields Grey_Wolf9 · Aug 15, 2018 at 03:57 PM 0
Share

Best advice I can give is to work on core program$$anonymous$$g concepts. Other people can help you fix problems, but you should have some idea of what that code should look like, else we're giving you a magic solution and that doesn't help you or anyone else with a similar problem learn.

avatar image Grey_Wolf9 RShields · Aug 15, 2018 at 04:02 PM 0
Share

okay i will do that

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

90 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 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 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 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 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 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 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

Check if Object is of Type Component 2 Answers

How to "Collapse all" components on gameobject in inspector window? 0 Answers

Add components to a list in inspector and then activate them at runtime? 1 Answer

A few questions here regarding AI 2 Answers

Open World In Unity 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