- Home /
'active' is not a member of 'System.Type'.
I'm trying to make an airbrake script. It should increase the drag on the rigidbody it's attached to, and enable/disable a GO. Here's the script.
var airbrake = GameObject;
function Start () {
airbrake.active = false;
rigidbody.drag = 0;
}
function Update () {
if(Input.GetKeyDown(KeyCode.LeftShift)){
airbrake.active = true;
rigidbody.drag = 10;
} else {
airbrake.active = false;
rigidbody.drag = 0;
}
}
Yet I get an error: 'active' is not a member of 'System.Type'. But I've disabled/enabled gameobjects this way before, so why is it not working now?! I have a script doing a similar thing, that on key press, it deactivates stuff and enables stuff, but this doesn't want to do it. HELP.
Please indent your code.. it looks like the source code of google.com :D
I dunno how to indent it, I use the default unity windows script editor- and it doesn't do auto indentation.
Just press the Tab key before a line to indent it! You also might want to consider switching to $$anonymous$$onoDevelop, it's quite nice.
As a side note, I think google.com's source code is intentionally unindented :) They probably run a utility to remove whitespace from their code so that it loads faster.
Answer by DallonF · Jun 25, 2011 at 03:27 PM
The problem is in your first line:
var airbrake = GameObject;
You're literally setting airbrake to equal the GameObject class. (I'm not sure of your experience with programming, but if you don't know what a class is, it would be a great idea to look it up)
This is the same issue that you would get if you did something like this:
GameObject.active = false; //should be gameObject.active = false
Tl;dr: I think you'll want to replace your first line with this:
var airbrake : GameObject;
I feel stupid now for not noticing that. Grr, oh well, thanks!
Thanks! This helped with my game ^_^ I would upvote if I had 15 rep
Answer by ckfinite · Jun 25, 2011 at 03:24 PM
Change
var airbrake = GameObject;
to
var airbrake : GameObject;
Your answer
