- Home /
Helicopter script error
I'm making a Unity helicopter using this tutorial
http://www.gotow.net/andrew/wordpress/?page_id=99
and I have a good script going:
var main_Rotor_GameObject : GameObject;
var tail_Rotor_GameObject : GameObject;
var max_Rotor_Force : float = 22241.1081;
var max_Rotor_Velocity : float = 7200;
static var rotor_Velocity : float = 0.0;
private var rotor_Rotation : float = 0.0;
var max_tail_Rotor_Force : float = 15000.0;
var max_Tail_Rotor_Velocity : float = 2200.0;
private var tail_Rotor_Velocity : float = 0.0;
private var tail_Rotor_Rotation : float = 0.0;
var forward_Rotor_Torque_Multiplier : float = 0.5;
var sideways_Rotor_Torque_Multiplier : float = 0.5;
static var main_Rotor_Active : boolean = true;
static var tail_Rotor_Active : boolean = true;
function FixedUpdate () {
var torqueValue : Vector3;
var controlTorque : Vector3 = Vector3(
Input.GetAxis( "Vertical" ) * forward_Rotor_Torque_Multiplier,
1.0,
-Input.GetAxis( "Horizontal2" ) * sideways_Rotor_Torque_Multiplier
);
if ( main_Rotor_Active == true ) {
torqueValue += (controlTorque * max_Rotor_Force * rotor_Velocity);
rigidbody.AddRelativeForce( Vector3.up * max_Rotor_Force * rotor_Velocity );
}
if ( Vector3.Angle( Vector3.up, transform.up ) < 80 ) {
transform.rotation = Quaternion.Slerp( transform.rotation,
Quaternion.Euler( 0, transform.rotation.eulerAngles.y, 0 ),
Time.deltaTime * rotor_Velocity * 2 );
}
if ( tail_Rotor_Active == true ) {
torqueValue -= (Vector3.up * max_tail_Rotor_Force * tail_Rotor_Velocity);
}
rigidbody.AddRelativeTorque( torqueValue );
function Update () {
}
if ( main_Rotor_Active == true ) {
main_Rotor_GameObject.transform.rotation = transform.rotation *
Quaternion.Euler( 0,
rotor_Rotation,
0
);
}
if ( tail_Rotor_Active == true ) {
tail_Rotor_GameObject.transform.rotation = transform.rotation *
Quaternion.Euler( tail_Rotor_Rotation,
0,
0
);
}
rotor_Rotation += max_Rotor_Velocity * rotor_Velocity * Time.deltaTime;
tail_Rotor_Rotation += max_Tail_Rotor_Velocity * rotor_Velocity * Time.deltaTime;
var hover_Rotor_Velocity = (rigidbody.mass * Mathf.Abs( Physics.gravity.y )
/ max_Rotor_Force);
var hover_Tail_Rotor_Velocity = (max_Rotor_Force * rotor_Velocity)
/ max_tail_Rotor_Force;
if ( Input.GetAxis( "Vertical2" ) != 0.0 ) {
rotor_Velocity += Input.GetAxis( "Vertical2" ) * 0.001;
}else{
rotor_Velocity = Mathf.Lerp( rotor_Velocity,
hover_Rotor_Velocity,
Time.deltaTime * Time.deltaTime * 5
);
}
tail_Rotor_Velocity = hover_Tail_Rotor_Velocity - Input.GetAxis( "Horizontal" );
if ( rotor_Velocity > 1.0 ) {
rotor_Velocity = 1.0;
}else if ( rotor_Velocity < 0.0 ) {
rotor_Velocity = 0.0;
}
}
And the error console says "Assets/Scripts/Helicopter_Script.js(3,24): BCE0044: unexpected char: 0xFB02." I really dont know what that means so any help would be great thanks
Looks like you have a dodgy character in there somewhere. Presumably on line 3 in position 24 - it looks like a space here perhaps it isn't in your script.
Answer by Wolfram · Jun 15, 2012 at 10:48 PM
Heh, 0xFB02 is a special character for a ligature of "fl". And indeed, if you try to select just the "f" of "float" in line 3, you see you can't select it without also selecting the "l".
To answer your question, just delete the word "float" in line 3, and type it again.
EDIT: woops, all other "float"s have the same problem. Don't copy the code out of the .pdf, just download the project.
Bloody good spot :) Do you just happen to know all of the Unicode characters by heart? In school they just taught me my times tables to 12.
Your answer
![](https://koobas.hobune.stream/wayback/20220613072833im_/https://answers.unity.com/themes/thub/images/avi.jpg)