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 Calum1015 · Apr 25, 2015 at 02:39 AM · unity 5errorupgradeartificial intelligencecs1061

Unity giving me some c sharp errors, cs1061

Hello Unity community! I am getting a problem from a script that I am trying to switch over from unity 4 to 5 in the asset bundle "Simply A*". I am getting three errors, all of level cs1061. I have looked over a few other posts and none have worked in my context. Here's the script:`using UnityEngine; using System.Collections; using System.Collections.Generic;

public class TDManager : MonoBehaviour { public GameObject start; public GameObject end; public GameObject tower; public GameObject ghostTower; public GameObject enemy; public Renderer rend;

 private List<GameObject> towers = new List<GameObject>();

 void Start()
 {
    StartCoroutine(SpawnEnemy());
    rend = GetComponent<Renderer>();
 }
 
 void Update () 
 {
     StartCoroutine(PlaceTowers());
 }

 private RaycastHit CheckPosition()
 {
     Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
     RaycastHit hit = new RaycastHit();

     if (Physics.Raycast(ray, out hit, Mathf.Infinity))
     {
         //Make sure to set towers in a grid, by rounding position to an int
         Vector3 newPos = hit.point;
         newPos.Set(Mathf.RoundToInt(newPos.x) - 0.5F, 0.4F, Mathf.RoundToInt(newPos.z) + 0.5F);
         ghostTower.transform.position = newPos;

         //Set color of "show" tower based on the spot being available
         if (hit.transform.tag == "Ground")
         {
             ghostTower.rend.material.color = Color.green;
         }
         else
         {
             ghostTower.rend.material.color = Color.red;
         }
     }
     else
     {
         ghostTower.rend.material.color = Color.red;
     }

     //Return all hit information which we use later
     return hit;
 }

 private IEnumerator PlaceTowers()
 {
     RaycastHit hit = CheckPosition();
     bool canPlace = false;
     //Make sure that we did hit something
     if (hit.transform != null)
     {
         canPlace = (hit.transform.tag == "Ground") ? true : false;
     }

     if (Input.GetButtonDown("Fire1") && canPlace)
     {
         GameObject newTower = Instantiate(tower, new Vector3(Mathf.RoundToInt(hit.point.x) - 0.5F, 0.3F, Mathf.RoundToInt(hit.point.z) + 0.5F), Quaternion.identity) as GameObject;
         towers.Add(newTower);
         yield return new WaitForEndOfFrame();
         Pathfinder.Instance.InsertInQueue(start.transform.position, end.transform.position, CheckRoute);
     }      
 }

 private void CheckRoute(List<Vector3> list)
 {     
     //If we get a list that is empty there is no path, and we blocked the road
     //Then remove the last added tower!
     if (list.Count < 1 || list == null)
     {
         if (towers.Count > 0)
         {
             GameObject g = towers[towers.Count - 1];
             towers.RemoveAt(towers.Count - 1);
             Destroy(g);
         }
     }
 }

 IEnumerator SpawnEnemy()
 {
     yield return new WaitForSeconds(1.5F);
     GameObject e = Instantiate(enemy, start.transform.position, Quaternion.identity) as GameObject;
     e.GetComponent<TDEnemy>().start = start.transform.position;
     e.GetComponent<TDEnemy>().end = end.transform.position;
     StartCoroutine(SpawnEnemy());
 }

} The errors are as follows:Assets/Pathfinding/Scenes/Scripts/TDManager.cs(42,28): error CS1061: Type UnityEngine.GameObject' does not contain a definition for rend' and no extension method rend' of type UnityEngine.GameObject' could be found (are you missing a using directive or an assembly reference?)` then Assets/Pathfinding/Scenes/Scripts/TDManager.cs(46,28): error CS1061: Type UnityEngine.GameObject' does not contain a definition for rend' and no extension method rend' of type UnityEngine.GameObject' could be found (are you missing a using directive or an assembly reference?) and finally, Assets/Pathfinding/Scenes/Scripts/TDManager.cs(51,24): error CS1061: Type UnityEngine.GameObject' does not contain a definition for rend' and no extension method rend' of type UnityEngine.GameObject' could be found (are you missing a using directive or an assembly reference?) Any help would be appreciated, thanks!

Comment
Add comment
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

1 Reply

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

Answer by flaviusxvii · Apr 25, 2015 at 02:56 AM

 canPlace = (hit.transform.tag == "Ground") ? true : false;

the == comparison is already returning a boolean value. It's confusing to wrap it with the ternary operator and just return the exact same value.

 ghostTower.rend

The variable 'ghostTower' is of type GameObject. "Type UnityEngine.GameObject' does not contain a definition for rend'" means that class GameObject does not have anything called "rend" in it.

You used to be able to directly access the renderer of a GameObject. Not anymore.

You'll have to do:

 ghostTower.GetComponent<Renderer>().material.color = Color.green;


Comment
Add comment · Show 1 · 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 Calum1015 · Apr 25, 2015 at 03:00 AM 0
Share

Sweet thanks, works great!

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

19 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

Related Questions

Unity 5 API Updater Keeps Failing 4 Answers

"Error building Player" WebGL build error 2 Answers

Sound files not working [Unity 5.1] 0 Answers

mac unity fbx import error 0 Answers

unity3d google play error [DF-RPC-01] 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