Hi I am having a bit of a problem with my character controller design.
My controllers are supposed to replicate this movement in this video at about 8:00
The hopes is to use a capacitor based thrusting movement for dog fighting/combat maneuvering and a third control (F “Normal Thrust”) as traditional thrust for transport between battle zones.
So the thrust timer (capLimit) is supposed to slow the vehicle (sphere for now) down in a realistic manner.
I had an example script that used lerping and the movement was right on the money, however it was in C# (I’m new and sticking to JS until I can get a hold on things) and the timer was constantly going. I want the timer only to go when thrusting.
Can someone help me with this thing. here is my incomplete code at the bottom. I think the lerp will go in the Accelerate, but I could definitely be wrong.
Help on this would be nice as I have yet to wrap my brain around Matf.Lerp.
The code is in the next post.
@script RequireComponent(CharacterController)
var speed : float = 0.0;
var accelerate : float = 1.0;
var thrustRate : float = 1.0;
var sensitivity : float = 0.01;
var canThrust : boolean = true;
var isThrusting : boolean = false;
var capLimit : float =1.0;
var speedLerp = speed;
private var fighter : CharacterController;
private var moveDirection : Vector3 = Vector3.zero;
function Start()
{
fighter = GetComponent(CharacterController);
}
function Update()
{
var mainThrust = Input.GetAxis("Normal Thrust");
Status();
if (isThrusting)
{
Accelerate();
}
else if (mainThrust > sensitivity)
{
MainThrust();
}
else
{
speed = 0;
}
moveDirection = Vector3(Input.GetAxis("X Axis"),Input.GetAxis("Y Axis"),Input.GetAxis("Z Axis") || Input.GetAxis("Normal Thrust"));
moveDirection = transform.TransformDirection(moveDirection);
fighter.Move(moveDirection * (Time.deltaTime *speed));
}
function Accelerate()
{
}
function Status()
{
var mainThrust = Input.GetAxis("Normal Thrust");
if (moveDirection != Vector3.zero mainThrust < sensitivity)
{
isThrusting = true;
}
else
{
isThrusting = false;
}
if (capLimit <= 0.0)
{
canThrust = false;
}
else if (capLimit > 0.0)
{
canThrust = true;
}
}
function MainThrust()
{
speed = accelerate;
}
LOL never mind I accidentally figured out how it works.