Simple Limited aircontrol

hey! i want to create Simple limited aircontrol when i jump.
i mean that i dont want it to be fully controllable,
but like half or one third control. so that i inherit the speed and direction from the jump, but can change like half, or a third while airbourne.

i was using the simple fpsWalker script with aircontrol at the end of this topic:
http://forum.unity3d.com/viewtopic.php?t=12065&start=5

my attempts have failed because of my undeveloped programmer thinking… so any help is appreciated.

You just need to add a separate airSpeed variable which is set to a value less than the grounded speed. Then multiply by the airSpeed value whenever the character is not grounded:-

var airSpeed: float = 3.0;
   ...

if (!grounded) { 
      moveDirection.x = Input.GetAxis("Horizontal")*airSpeed; 
      moveDirection.z = Input.GetAxis("Vertical")*airSpeed; 
}

this slowed down the whole aereal speed. it does not keep the initial speed that he got before the jump.

i think i need to create another vector, just for air movement…

anyway, thanks for the feedback!

you’d also have to make sure that the character is actually falling by comparing y-values (or whatever “down” is in your game) if not grounded before you apply the airSpeed factor.

private var isFalling: bool = false;
private var oldY: float;

[...]

//meanwhile in update()...
if (!grounded)
{
	if (oldY > transform.position.y) isFalling = true;
	if (isFalling)
	//apply airSpeed factor
}
else
{
	isFalling = false;
}

[...]

//end of update()...
oldY = transform.position.y;

(I didn’t test this, but I guess you get the idea.)

i havent had any problems with moveDirection.y
since im specifically working with X and Z
thanks anyway, probably gonna add that so i can mix with the Y parameter.

the thing is that the X and Z speed is slowed down when i jump if i use that variable for airspeed.
since it replaces speed for the whole vector.

what i cannot code, but what i would need. Is either a secondary vector that only works in air, or ill use that other fully air controlalbe script and use a negative vector to multiply with.

or some way to only change movedirection while !grounded. not replacing it, just changing it within its usual limits.

let me clarify what i would want to do:

i would like to create another vector, that works additive to the current one.

i dont know how to implement that in the code, since the current is spesifically made for the char controller. so i always mess up the vector direction somehow.