x


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.

more ▼

asked Jan 15 '12 at 05:53 PM

twoface262 gravatar image

twoface262
129 40 52 55

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Jan 15 '12 at 06:09 PM

Eric5h5 gravatar image

Eric5h5
80.3k 42 132 521

Now I'm getting an error in this

_NetworkRigidbody.enabled = false;

the error is

Assets/NetworkFiles/Plugins/RigidAssign.js(14,40): BCE0005: Unknown identifier: 'NetworkRigidbody'.

Jan 15 '12 at 06:54 PM twoface262
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x4165
x3739
x3460
x710

asked: Jan 15 '12 at 05:53 PM

Seen: 1035 times

Last Updated: Jan 15 '12 at 06:54 PM