- Home /
GetComponent Help.
Hello, I'm having a problem with my "getcomponent" and I'm unsure what to do. Here is where it is giving me the error. This is from java script it is trying to get a class out of a c# script.
var _NetworkRigidbody : NetworkRigidbody = GetComponent("NetworkRigidbody");
and this is the error its giving me.
Assets/NetworkFiles/Plugins/RigidAssign.js(14,27): BCE0018: The name 'NetworkRigidbody' does not denote a valid type ('not found'). Did you mean 'UnityEngine.NetworkReachability'?
Thanks if you help me.
Answer by Eric5h5 · Jan 15, 2012 at 06:09 PM
If you have the C# script compiled earlier, then you can use
var _NetworkRigidbody = GetComponent(NetworkRigidbody);
If it's not possible to have the C# script compiled earlier, then you have to do
var _NetworkRigidbody = GetComponent("NetworkRigidbody");
Using strings returns Component instead of the type, but that relies on dynamic typing, so _NetworkRigidbody becomes Object instead of NetworkRigidbody, which won't work in a non-#pragma strict environment.
Now I'm getting an error in this
_NetworkRigidbody.enabled = false;
the error is
Assets/NetworkFiles/Plugins/RigidAssign.js(14,40): BCE0005: $$anonymous$$ identifier: 'NetworkRigidbody'.
Your answer
Follow this Question
Related Questions
RPC kill counter 1 Answer
convert c# to JavaScript Problem 0 Answers
Making changes to a terrian in game 1 Answer
Send a variable from javascript to a C# Application 0 Answers
A node in a childnode? 1 Answer