Help with error please.

I’m getting an error in the console and I’m confused about what its telling me. I’m still only a noob with this sort of thing so please help me out. The error states Assets/HoverCar.js(49,29): BCE0024: The type ‘Tilt’ does not have a visible constructor that matches the argument list ‘(String)’.

and here is the script.

var driveForce: float;

var hoverHeight: float;
var thrustForce: float;
var steerForce: float;
var steerPosZ: float;
var damping: float;
var turnspeed: float;
var Tilt: Vector3;

var thrusters: Vector3[];




function FixedUpdate () {
	var hit: RaycastHit;
	
	for (i = 0; i < thrusters.Length; i++) {
		var wdThruster: Vector3 = transform.TransformPoint(thrusters[i]);
		
		if (Physics.Raycast(wdThruster, -transform.up, hit)) {
			var discrep: float = hoverHeight - hit.distance;
			var upVel: float = rigidbody.GetRelativePointVelocity(wdThruster).y;
			rigidbody.AddForceAtPosition(transform.up * (thrustForce * discrep - upVel * damping), wdThruster);
		}
	}
	
	var fwd: float = Input.GetAxis("Vertical");
	rigidbody.AddForce(transform.forward * (driveForce * fwd));
	
	var steer: float = -Input.GetAxis("Horizontal");
	rigidbody.AddForceAtPosition(transform.right * (steerForce * steer), transform.TransformPoint(Vector3.forward * steerPosZ));
}


function OnDrawGizmos() {
	for (i = 0; i < thrusters.Length; i++) {
		Gizmos.DrawWireSphere(transform.TransformPoint(thrusters[i]), 0.1);
	}
	
}

	// Turning
	if (Input.GetButton("Left")){
		transform.eulerAngles.y += -turnspeed * Time.deltaTime;
		// Tilt
		if(transform.eulerAngles.z >= 315 || transform.eulerAngles.z <= 45){
			Tilt("left");
		}
		
	}else if (Input.GetButton("Right")){
	transform.eulerAngles.y += turnspeed * Time.deltaTime;
		//tilt
		if(transform.eulerAngles.z <= 45 || transform.eulerAngles.z >= 315){
			Tilt("right");
		}
	}else{ //no turn
		if (transform.eulerAngles.z < 357.5  transform.eulerAngles.z > 315){
			Tilt("right");
		}
		else if (transform.eulerAngles.z > 2.5  transform.eulerAngles.z < 45){
			Tilt("left");
		}
	}

Thanks

hi,
you can’t write Tilt(“right”) but you have to use Tilt.right cz that’s how you use a vector 3.

If I do that another error comes up Assets/HoverCar.js(56,30): BCE0034: Expressions in statements must only be executed for their side-effects.

so use Vector3 directly without any instance;

Vector3.right

Same error with Vector3.right I can’t honestly work this out. I’m thinking It might be a float and not a vector

what are you trying to do here?

Its a script that I can attach to an object and it makes the object hover. When turning the object is meant to tilt left or right like the game Wipeout or F-zero if you can find a youtube video you will see what I mean.

http://www.youtube.com/watch?v=dxBZKjWz7L4

hi add that:
transform.position=Vector3.left;

cz you are telling the object to change its position to the left so you can’t write Vector3.right with nothing else.

I am sorry Vector3.right*-1;
or Vector3.right
cz you cannot use the Vector3.left;
this worked with me.

Vector3.right*-1 ----> means Vector3.left

Thanks it works fine now, your welcome to use the script for yourself :slight_smile:

Hi W4RH4WK117,

I am a newby and I was trying to use your code to make a box hover but it starts flying away without any control… I tried to tweak the values someway but it didn’t work, could you please tell me if you used some particular configuration?

Thanks a lot, best regards
Fabio