Hello
I am trying to do code where there is 3 cubes on the scene and when I press tab key it will change the target.
That is working well no problems.
but it dont show the selected color anywhere, if I press tab key it will select the target but it dont change its color!
this is the script and the problem what it debug says.
private void SelectTarget()
** {**
** selectedTarget.renderer.material.color = Color.yellow;**
** PlayerAttack pa = (PlayerAttack)GetComponent(“PlayerAttack”);**
** pa.target = selectedTarget.gameObject;**
** }**
** private void DeselectTarget()**
** {**
** selectedTarget.renderer.material.color = Color.green;**
** selectedTarget = null;**
** }**
And the debug problem : MissingComponentException: There is no ‘Renderer’ attached to the “Enemy 1” game object, but a script is trying to access it.
You probably need to add a Renderer to the game object “Enemy 1”. Or your script needs to check if the component is attached before using it.
so the problem is on the renderer part so what I need to add the enemy cubies? thx