jerks appearing while moving the character continuosly

Hi,

I am working on a game in which i am moving the character continuously in one direction. For doing so i am using character controller on the character but still some jerks are appearing in the game play.

var c : CharacterController;
 var speed : float;
var jumpspeed : float;
var moveDirection : Vector3;
var vel : Vector3;



function Start()
{	
	c=GetComponent(CharacterController);
}
//
function FixedUpdate () 
{

	
moveDirection=transform.TransformDirection(Vector3.forward);
moveDirection*=speed;

if(c.isGrounded)
{
	if(Input.GetButton("Jump"))
		{
			vel.y=3.5;
		}

}
else
{

vel.y+=Physics.gravity.y*Time.deltaTime;

}

moveDirection+=vel;

c.Move(moveDirection*Time.deltaTime);

}

do you have a collider on your character ?

I am using character controller …so i dont need any collider…is there any problem in the scripting??

Replace Fixed update with Update and instead of Time.deltaTime I would recommend using Time.smoothDeltaTime.

1 Like

thnx buddy …it really works …thnx a ton

Can i make it more smoother !!! can i alter the value of Time.smoothdeltatime… ?

Time.smoothdeltatime is read only.

The only thing you could make more is to calculate your own deltaTime and also try to smooth that too.

I had many issues with unity’s delta time also. It seems that it is an old issue that has never taken care of.

thanx buddy…it really works…

could you please share some code? I have been unable to make something move across the 2D screen smoothly. I’m just moving some obstacles for my main character to avoid, they probably don’t need their own character controllers but I’m getting desperate.