JetPack script problem.

got scripts? Need scripts?
Post Reply
User avatar
VZdemon
Posts: 93
Joined: Thu Nov 25, 2010 1:55 pm

JetPack script problem.

Post by VZdemon »

i have this problem with my etpack script, when ever i'm in the air i can't move i can only rotate.

here is my jetpack script.

Code: Select all

var fire : Transform;
var fuel : float = 100.0;
var exel : float = 0.2;

private var nextBoost : float = 0.0;
public static var torque : float = 0.0;

function Update(){
	var controller : CharacterController = GetComponent(CharacterController);
	
	if(Input.GetButton("Jump")){
		if(fuel>0){
			fire.renderer.enabled = true;
			if(Time.time > nextBoost){
				nextBoost = Time.time + exel;
				torque++;
				fuel--;
			}
		}else{
			fire.renderer.enabled = false;
			torque=0;
		}
	}else{
		fire.renderer.enabled = false;
		if(torque>0){
			torque--;
		}
	}
	
	controller.Move(Vector3.up * torque);
}
here is my player script.

Code: Select all

var speed : float = 3.0;
var rotateSpeed : float = 3.0;
var spawn : Transform;

function Update () {
    var controller : CharacterController = GetComponent(CharacterController);
    transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0);
	
    var forward : Vector3 = transform.TransformDirection(Vector3.forward);
    var curSpeed : float = speed * Input.GetAxis ("Vertical");
    controller.SimpleMove(forward * curSpeed);
}

function OnControllerColliderHit(hit : ControllerColliderHit)
{
	if(hit.gameObject.tag=="catcher")
	{
		transform.position = spawn.position;
	}
}

@script RequireComponent(CharacterController)
if any1 could please find the problem i would be wounderfull since i am sitting on the computer trying to figuer this out for about 5 days.
it's VZdaemon on xbox live
User avatar
SpiritWebb
Posts: 3107
Joined: Sun Jul 12, 2009 11:25 pm

Re: JetPack script problem.

Post by SpiritWebb »

It looks like your only calling the lift/jump button in your jetpack control script. You will need to add a if statement for your forward, left, right and back controls if you want to control your character...

This is the only option you have for your Jet pack:

Code: Select all

if(Input.GetButton("Jump")){
      if(fuel>0){
         fire.renderer.enabled = true;
         if(Time.time > nextBoost){
            nextBoost = Time.time + exel;
            torque++;
            fuel--;
Image

Image
Post Reply

Return to “Scripting/Coding”