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 /
avatar image
0
Question by Kek_Kek · May 24, 2018 at 06:16 PM · score systempainting

Painting Scoring system

Is their a way to get a texture and have it so that if a player paints one of the pixels with the right color, he gets 5 points. For example I have a 2d pixel apple. The player has to try and redraw the apple as best as he could. If he uses red and paints the apple correctly, he gets those 5 points. Is it possible for something like this and if so, what are some of the steps to create this?

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 Temseii · May 24, 2018 at 06:27 PM 0
Share

Do you have any of the functionality in place yet? How are you letting the user choose a color to use?

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Temseii · May 24, 2018 at 06:34 PM

     private Color chosenColor;
     private int _points;
 
     private Color AppleColor { get { return Color.red; } }
 
     private void CheckColor() {
         if(chosenColor == AppleColor) {
             _points += 5;
         }
     }


Something like that?

Comment
Add comment · Show 3 · 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 Kek_Kek · May 24, 2018 at 07:49 PM 0
Share

I belive the script would be more complex than that. The apple was used as an example but what would happen is that the user has to redraw famous paintings. He would be able to pick what color to use by using a RGB color selector. To make things easier for the player there it wouldnt be the exact color but one thats close.

avatar image Temseii Kek_Kek · May 24, 2018 at 08:40 PM 0
Share

I'm sure it will be. Have you written any sort of base for what you're trying to do here or are you trying to get it done for you? It's a little hard to say where your skill level is at and how much help you actually need without you having submitted any code with your post.

avatar image Kek_Kek Temseii · May 24, 2018 at 08:48 PM 0
Share

I was using a color picker I found as a base for picking a color. I am working on the drawing mechanic using the color picker. I wanted to know if there was a way to have a scoring system depending on what you paint.

Here is the link to the color picker im using.

link text

avatar image
0

Answer by Tobychappell · May 24, 2018 at 10:39 PM

An approach that i think might work is that when the painting is done, you'd compare pixel by pixel (or maybe a 4x4 group of pixels that have their color averaged) of the original(source) and the new painting(target). You may want to give tolerances as getting the EXACT color value will be next to impossible (1 / 2^24 ?). If you exclude the alpha channel and just work with RGB, you get a Vector3. So this tolerance can be the 'max distance' from source to target. and possibly have tiers of tolerances that correspond to points awarded.

demo code:

 Texture2D source;
 Texture2D target;
 float maxTolerance = 1.0f / 16.0f;

 void CheckTextures()
 {
 if(source == null || target == null)
 {
   Debug.Log("source or target texture not initialised");
   return;
 }

 if(source.width != target.width || source.height != target.height)
 {
   Debug.Log("source and target textures are not the same width or height");
   return;
 }
 
 for (int x = 0; x < source.width; x++)
 {
   for (int y = 0; y < source.height; y++)
   {
     Color sourceColor = source.GetPixel(x,y);
     Color targetColor = target.GetPixel(x,y);

     Vector3 sourcePos = new Vector3(sourceColor.r, sourceColor.g, sourceColor.b);
     Vector3 targetPos = new Vector3(targetColor.r, targetColor.g, targetColor.b);

     if (Vector3.Distance(sourcePos, targetPos) <= maxTolerance)
     {
       // Grant points
     }
   }
 }
 }

Comment
Add comment · Show 3 · 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 Kek_Kek · May 25, 2018 at 01:21 AM 0
Share

Ok I will test this to see if it works

avatar image Kek_Kek · May 25, 2018 at 01:56 AM 0
Share

Im getting this error error CS0103: The name `tex' does not exist in the current context

avatar image Tobychappell · May 25, 2018 at 11:17 AM 0
Share

Apologies that should be source

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

84 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

Related Questions

Painting terrain problem 12 Answers

Painting materials 1 Answer

Coloring 3d model using camera 0 Answers

Pause Time.time? 1 Answer

Im Doing HighScore System To My Game And There Is Something Wrong In My Scripts 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