Lets say I have 2 classes,
Weapon and First Aid. Then I have a variable called item whose type is Weapon(var item : Weapon). Would there be a way for me to change item form a Weapon to First Aid;
Lets say I have 2 classes,
Weapon and First Aid. Then I have a variable called item whose type is Weapon(var item : Weapon). Would there be a way for me to change item form a Weapon to First Aid;
Try removing #pragma strict and let unity do the dynamic typing, which should change the type on fly.
Just ensure that it doesn’t require it to do any more dynamic typing.
As follows, perhaps, setting item:Object would work, then logically, you would be able to use different classes through it
you might ned to google about type cast and “as” keyword
You can have a class which is multiple types through interfaces. If your item implements interfaces IWeapon and IFirstAid then you can use that item as both types.
Alternatively, if both First Aid and Weapon share behaviour, you can use an Abstract class, say AbstractItem, which your Weapon and First Aid classes extend.
This works in C#, I don’t know how well interfaces are working in UnityScript…