It’s been a while (a few years, actually) since I picked up Unity and I’m trying to get back into it. From what I’ve seen so far, #pragma strict
appears to be all the rage lately. However, it apparently doesn’t use dynamic typing, which I think is the root of my issue. I’m simply trying to pass an instance of a class from one script to another. However, I’m getting this error:
‘name’ is not a member of ‘Object’
When I attempt to run this code:
In Item.js:
function OnTriggerEnter(other : Collider) {
if(other.gameObject.CompareTag("Player")) {
var weapon = new PlayerItem("Test Weapon Name");
other.SendMessage("AddItemToInventory", weapon);
}
}
In PlayerInventory.js:
class PlayerItem {
var name : String;
function PlayerItem(g_name : String) {
name = g_name;
}
}
function AddItemToInventory(itemProperties) {
Debug.Log(itemProperties.name);
}
Where did I go wrong? UnityScript today isn’t the UnityScript I remember. Heh.