- Home /
Question by
Ssiroo · Aug 06, 2014 at 10:12 PM ·
javascriptvariablegetcomponent
GetComponent from class
Hello, Im trying to change a variable of a script from another script but it just won't work.
The sript im trying to acces(A part of it) :
class CharacterMotorJumping {
var enabled : boolean = true;
var baseHeight : float = 1.0;
var extraHeight : float = 4.1;
var perpAmount : float = 0.0;
var steepPerpAmount : float = 0.5;
}
The part where I try to access it :
var characterMotor : CharacterMotor;
function Start()
{
characterMotor = transform.GetComponent(CharacterMotor);
}
if(isWeapon==false && canShoot==false)
{
characterMotor.baseHeight = 5.0;
}
It's giving me this error :
BCE0019: 'baseHeight' is not a member of 'CharacterMotor'.
I think it's because the variable Im trying to access is part of a class. Im new in scripting so please don't hate me if the solution is super simple and obvious. I googled for hours but couldn't find anything.
Thank you.
Comment
Best Answer
Answer by Ssiroo · Aug 06, 2014 at 10:26 PM
I fixed it. Played around with the script for a while and replaced the line :
characterMotor.baseHeight = 5.0;
with this line :
characterMotor.jumping.baseHeight = 10;
Thank you.