Quantcast
Channel: Questions in topic: "error message"
Viewing all articles
Browse latest Browse all 2891

Variable changing from other script does not work.

$
0
0
Good time of day to everybody. Currently, I am making a little strategy game in which you can select and command units. I have written a little script for selecting units on the gamefield. However, as is with any script that I write on my own, it does not work. It should work but it has two problems: 1. It does not recognize the isSeleted bool 2. It throws in this error "Expression denotes a method group, where a variable, value or type was expected." Here is my code: void Update () { units = GameObject.FindGameObjectsWithTag ("Unit"); if (Input.GetMouseButtonDown (0)) { RaycastHit2D hit = Physics2D.Raycast (transform.position, Input.mousePosition); if (hit != null && hit.collider != null) { hit.transform.GetComponent.isSelected = true; } } } Here is the script I am trying to access: void Update (){ if (isSelected) { Debug.Log ("I am the chosen one!"); } }

Viewing all articles
Browse latest Browse all 2891

Trending Articles



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