djary
1
hi all
i have 2 script
- CaseDamage.js
and
2. KillStrikeCamera.js
but give error
Assets/killstrike/scripts/killStrikeCamera.js(14,21): BCE0005: Unknown identifier: ‘CasE’.
CaseDamage attached to “CasE” Object
and KillStrikeCamera.js attached to ither camera
Your using a variable CasE which does not seem to exist. Try
* *GetComponent(CaseDamage).killStrikeCheck ;* *
instead of
* *CasE.GetComponent(CaseDamage).killStrikeCheck ;* *
djary
3
yes worked !
but why sometime we should use gameobject.GetComponent(scriptname).Varibale
?
You should really study the basics and read some good guides. There is plenty of documentation out there to explain it.
GameObject go = GameObject.Find(“SomeGo”);
go.GetComponent().DoSomething();
will execute the function DoSomething in the script Something attatched to a GameObject called SomeGo.
gameObject.GetComponent().DoSomething();
will execute the function DoSomething in the script Something attached to the same GameObject as the script calling this.