Getting component from c# to java script
Hi all i have problem with my game because in one script i want to script to get component from 'SmoothFollow' script "" var cam = Camera.main;
cam.GetComponent(SmoothFollow).target = newball;''
but when i click save and wanted to play im getting this error '' BCE0005: Unknown identifier: 'SmoothFollow'. but i have this script in my asset folder same capital letters and in the script target is also with small letter so i have no idea whats wrong :/ Can anyone help :? Thanks!
Answer by Positive7 · Sep 05, 2015 at 08:25 PM
UnityScript gets compiled before C# . There're couple of workarounds for example in docs : http://docs.unity3d.com/Manual/ScriptCompileOrderFolders.html
Hmm still didnt get it i tried putting it to folders in standard assets the smoothfollow scirpt also tried to put to utility folder camera script still doesnt work im looking at the code and thinking maybe there is some other way, all i need is when a player enters collider it changed to different prefab [i got that] but then it gets component from main camera 'target' to follow new target
I did and still same problem ''CE0005: $$anonymous$$ identifier: 'SmoothFollow'.''
Ohh ok
Under your #pragma strict
insert this
import UnityStandardAssets.Utility;
and in SmoothFollow.cs change
private Transform target;
to
public Transform target;
for some reason java ignores the [SerializeField]
thingy above it :(
Your answer
![](https://koobas.hobune.stream/wayback/20220612002756im_/https://answers.unity.com/themes/thub/images/avi.jpg)