Quantcast
Channel: Latest Questions by Calum1015
Viewing all articles
Browse latest Browse all 19

Unity giving me some c sharp errors, cs1061

$
0
0
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 towers = new List(); void Start() { StartCoroutine(SpawnEnemy()); rend = GetComponent(); } 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 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().start = start.transform.position; e.GetComponent().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!

Viewing all articles
Browse latest Browse all 19

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>