How to accelerate a character controller?

Hi,

I am using a CharacterController and it’s Move() function to move my character around. It’s also a kinematic rigidbody, as I DONT want it to react to physics forces in the game, for a reason. I have the velocity vector, that updates based on user input, at every frame. Given that, if I simply do cc.Move(velocityVector), the character moves with a constant speed. I am wondering , is there a way to make the character accelerate (or deccelerate) so that the speed increases over time (till it reaches a maximum speed).

I also want the character to respond to colliders in the game so that when it hits a wall or a ground, it stops instantly. And the next time the character starts moving, it starts with zero speed accelerating all that way to it’s maximum.

Is there a way to achieve this?

Thanks!

hi,try to increase speed with time only and if speed reaches the maximum,speed=maxmum speed.and for colliders use the function OnCollisionEnter(col:Collision) and if (col.gameObject.tag==“Collisionobjectsname” )
{
make the speed of the rigidbody to zero;
yielld WaitforSeconds(1);
IncreaseSpeed();
}

function Update()
{
IncreaseSpeed();
}
var speed:int=0;
var maxspeed:int=15;
function IncreaseSpeed()
{
transform.Translate(Vector3.forwardspeedTime.deltaTime);
speed+=1;
if(speed==“maxspeed”)
{
speed=maxspeed;
}
}

May be this might work

You don’t need the rigidbody to keep track of velocity

CharacterController.velocity

After clocking the cc.v you can then return a magnitude. Then set a condition to control the magnitude.

Thanks guys for the help. I kinda figured rather a simple solution to this. For one, you don’t need to rigidbody at all (makes total sense to me if I’m using CharacterController to move the character around). So I took that out of my way. Second, I use the following set of simple equations to get the kind of result I am looking for:

Vector3 velocity;
Vector3 acceleration;
float speed;
CharacterController cc;
Vector3 moveVector;


void Update()
{
    //My velocity is the gravity which changes with the device's orientation. 
     velocity = DeviceInput.gravity //gravity changes with device's tilt and the character moves in response to the change in gravity.
     acceleration = velocity + cc.velocity;
     moveVector *= speed * Time.deltaTime;
     cc.Move(moveVector);

}

Obviously, I can fine tune this to get a smoother acceleration rate.