Unityscript accessing a Class within a Class

Hi everyone, I have been trying to access the gravity variable in the Character Motor of the first person controller in the Unity standard assets package.

ut I’m not sure how. It’s in another class called CharacterMotorMovement within the class of CharacterMotor and I can’t access it with the getcomponent method.

I simply want to be able to turn off gravity for the controller in a script. So How would I access the gravity variable?

Someone has to say, this is just too long to post other than in exceptional circumstances.

I did not even look at the script since it is just Unity CC script. What is the point of posting something anyone can find on his computer...

excellent point

1 Answer

1

You can access the CharacterMotorMovement like how you would access a variable. If this script is named CharacterMotor.js, then you can do something like this:

var cm = someGameObject.GetComponent.<CharacterMotor>();

//Getting the collisionFlags defined in the CharacterMotorMovement
CollisionFlags cf = cm.movement.collisionFlags;