- Home /
GetComponent of Camera? C# Type Unityengine.Target error
Okay. My Netcode when it spawns a player has to change the cameras "Smooth Follow" scripts target to the players object. Note. The smooth follow is written in JS but my netcode is in c#. I have tried a few examples and failed. The camera is called Camera. Any advice?
Heres what im trying:
GameObject objectwithscript;
Component followscript;
objectwithscript = GameObject.Find ("Camera");
followscript = objectwithscript.GetComponent ("Smooth Follow");
followscript.Target = Localhostplayer;
Updated it with my attempted code. Please look over. The error i get is:Type UnityEngine.Component does not contain a definition for Target and no extension method....
Sorry to bump. But need desperate help on this! I get a Type: unity engine.componenet does not contain definition for target?
Answer by robertbu · Dec 11, 2013 at 05:48 PM
Move your "Smooth Follow" script into 'Standard Assets'.
Answer by karljj1 · Dec 11, 2013 at 05:50 PM
If your calling GetComponent of a js script from c# you need to either have the js script in a Plugins directory so its compiled first or use GetComponent("SmoothFollow") .
Your answer
Follow this Question
Related Questions
How do I let a camera follow on one axis? 3 Answers
Rotating camera problem C# Android 2 Answers
Camera Border Follow 1 Answer
Camera follow mouse around the map 2 Answers