So in my script i have a "Monster" (a box) with a script that has the function:
var Player: Transform; function OnMouseOver () { if (Input.GetMouseButtonDown(1)) { Player.SendMessage ("AttackMonster"); } }
I have the player set up as the character (obviously) and on that i have this script:
function AttackMonster() { print ("ATTACK"); }
now all this works just fine and dandy, no problems at all. But i want the "Monster" to send its location to the other script, so that way i can have the script move the player to the monsters location. I tried adding a var with the position:
var Player: Transform; var targetPoint = transform.position; function OnMouseOver () { if (Input.GetMouseButtonDown(1)) { Player.SendMessage ("AttackMonster",targetPoint,SendMessageOptions.DontRequireReceiver); } }
I kept getting an Error saying that i cant call that function when declaring a variable, can i fix this? or do i have to do something completely different?