Then you should use GetComponent to reference “WoodGet” from the other script. Here’s a simple way of doing it :
var yourGameObject : Transform; // The GameObject that has the Script.
function OnGUI(){
var woodGet = yourGameObject.GetComponent("NameOfTheScript").WoodGet;
Yes this GiveWood.js is in Cube and i assigned this Cube to the getscript in inspector tab, look: http://imageshack.com/a/img35/5207/of20.png
If u dont know what’s wrong i can give u full WeaponSwitch and Givewood scripts, maybe this help.
I don’t get it
gameObject, u mean WoodGiver (Cube) ?
I need this GiveWood.js to be attached with WoodGiver, because it check my hit (if i hit it then display message).
Or maybe i must put this var getscript : Transform;
to WeaponSystem and attach WoodGiver to it ?
Sorry, but i don’t get it, im new ;D
My WeaponSystem need to be attached with “Meele” (u can see it on my screenshot)
Basically, the variable getScript needs to reference the WeaponSystem script. So you’ll have to assign it with a gameObject( any object in your scene ) that has the WeaponSystem.js attached to it.
If “Meele” has the WeaponSystem.js attached to it, then assign “Meele” as the getScript variable in the inspector.
U are my master ! My GOD . Thank you so much :****
I have another problem but not with this it just show in console and i dont know what is this
NullReferenceException: Object reference not set to an instance of an object
UnityEditor.Graphs.AnimationStateMachine.TransitionInspector.OnEnable () (at C:/BuildAgent/work/d3d49558e4d408f4/Editor/Graphs/UnityEditor.Graphs/AnimationStateMachine/TransitionInspector.cs:71)
And if i want place there some graphic not text what i must do ?
The 1st error is letting you know that an object you’ve assigned isn’t being referenced correctly.
I’m not quite sure what that 2nd error is - Try re-staring Unity and maybe it’ll go away.
If you want Graphics then you can use GUI.DrawTexture to display an image on the screen…