• 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 Nocturnal_Glow · May 30, 2015 at 11:38 AM · type

Error CS0029 Urgent help needed

hey was wondering if anyone knows why I'm getting the error "board.cs(40,25): errorCS0029: cannot implicit convert type 'void' to 'bool'

my code for Board.cs is as follows:

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
     public class Board : MonoBehaviour {
     public List<Egg> Eggs = new List<Egg>();
     public int GridWidth;
     public int GridHeight;
     public GameObject EggPrefab;
     public Egg lastEgg;
 
     // Use this for initialization
     void Start () {
         for (int y=0; y<GridHeight; y++) {
             for (int x=0; x<GridWidth; x++) {
                 GameObject g = Instantiate(EggPrefab,new Vector3(x,y,0),Quaternion.identity)as GameObject;
                 g.transform.parent=gameObject.transform;
                 Eggs.Add(g.GetComponent<Egg>());
             }
         }
         gameObject.transform.position = new Vector3 (-4.52f, -4.34f, 0);
     }
     
     // Update is called once per frame
     void Update () {
     
     }
 
     public void SwapEggs(Egg currentEgg)
     {
         if (lastEgg == null) 
         {
             lastEgg = currentEgg;
         } 
         else if (lastEgg == currentEgg) 
         {
             lastEgg = null;
         } 
         else 
         {
             if(lastEgg.IsNeighborWith(currentEgg))
 
             {
 
             }
             else 
             {
                 lastEgg.ToggleSelector ();
                 lastEgg = currentEgg;
             }
         }
     }
 }
Comment
Add comment · Show 2
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 karl_jones ♦♦ · May 30, 2015 at 11:40 AM 0
Share

Can you post the code for IsNeighborWith? Looks like it does not return a value but you are treating it like it returns a bool.

avatar image Nocturnal_Glow · May 30, 2015 at 01:07 PM 0
Share

here is the connected Egg.cs document code

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 public class Egg : $$anonymous$$onoBehaviour {
     public GameObject Shpere;
     public GameObject Selector;
     string[]Egg$$anonymous$$ats = {"Red","Blue","Green","Yellow","Black","Purple","Orange"};
     string color="";
     public List<Egg>Neighbors = new List<Egg>();
     public bool isSelected = false;
 
     // Use this for initialization
     void Start () {
         CreateEgg ();
     }
     
     // Update is called once per frame
     void Update () {
     
     }
     public void ToggleSelector()
     {
         isSelected = !isSelected;
         Selector.SetActive (isSelected);
     }
     public void CreateEgg()
     {
         color = Egg$$anonymous$$ats[Random.Range(0,Egg$$anonymous$$ats.Length)];
         $$anonymous$$aterial m = Resources.Load ("$$anonymous$$aterials/" + color) as $$anonymous$$aterial;
         Shpere.renderer.material = m;
     }
     public void AddNeighbor(Egg g)
     {
         if (!Neighbors.Contains (g))
                 Neighbors.Add (g);
     }
     public void IsNeighborWith(Egg g)
     {
         if (Neighbors.Contains (g)) 
         {
             return true;
         }
         return false;
     }
     public void RemoveNeighbor(Egg g)
     {
         Neighbors.Remove (g);
     }
     void On$$anonymous$$ouseDown()
     {
         ToggleSelector ();
         GameObject.Find ("Board").GetComponent<Board> ().SwapEggs (this);
     }
 }


1 Reply

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

Answer by karl_jones · May 30, 2015 at 02:42 PM

IsNeighborWith should return a bool not void.

Public bool IsNeighbourWith

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Turn Strings[] into vars[]? 1 Answer

how to typecast a method holder in Javascript, like Delegate 1 Answer

Combining Boo and C# 1 Answer

Convert String to a type 1 Answer

Build Queue Logic In Turn-based Strategy 1 Answer


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