So I tried to make a very simple script where if the cube “Money” collided with “Player” (My FP controller), The variable TheMoney would increase by 50… BUT I’m getting an error saying that Money is not a member of UnityEngine.GameObject
This script is attached to the cube called “Money” and the cube has a Box Collider and a Rigid Body (BTW this is Javascript)
MY CODE:
#pragma strict
var col : Collision;
var MoneyAmount : int = 50;
var CurrentMoney : int = 0;
function OnCollisionEnter (col : Collision) {
if (col.gameObject.Money == "Player") {
CurrentMoney = CurrentMoney + MoneyAmount;
}
}