- Home /
Question by
Anwar_10 · Apr 01, 2014 at 08:44 AM ·
animationrigidbodycollidercharactercontrollercapsulecollider
When jump my character controller model it goes out of collider
when I am jumping my character controller model then it jump but it goes out of character controller collider and when it comes in running state then it is perfectly with character controller collider. So please help me anyone for this problem. I am using following code :-
void Update() {
if(isMove == false && Menu.isPlay == true) { controller.Move(new Vector3(-Input.acceleration.y 50.0f Time.deltaTime,0,0)); controller.Move(Vector3.forward 30.0f Time.deltaTime);
animation.Play("run");
if(controller.isGrounded)
{
PlayAnimation("run");
}
else
{
CheckForIdle();
}
}
if(Input.GetKey(KeyCode.Space) && !jumping) { //Debug.Log("Jumping 222"); jumping = true; isMove = true; isSlide = false; PlayAnimation("jump"); gravity = jumpforce;
}
if(Input.GetKey(KeyCode.DownArrow) && !jumping) { isSlide = true; isMove = true; jumping = false;
PlayAnimation("slide");
}
if(jumping == true )
{
controller.Move(Vector3.forward * 30.0f * Time.deltaTime);
controller.Move(Vector3.up * 2.0f * gravity * Time.deltaTime);
gravity -= gravityfall * Time.deltaTime;
if(controller.isGrounded )
{
jumping = false;
isMove = false;
isSlide = false;
}
}
if(!controller.isGrounded && !jumping)
{
controller.Move(Vector3.up * gravity * Time.deltaTime);
gravity -= gravityfall * Time.deltaTime;
}
}
void PlayAnimation ( string AnimName )
{
if (!animation.IsPlaying(AnimName))
{
animation.CrossFadeQueued(AnimName, 0.5f, QueueMode.PlayNow);
}
}
void CheckForIdle ()
{
if (animation.IsPlaying("run"))
PlayAnimation("idle1");
if (!animation.isPlaying)
animation.Play("idle1");
}
Comment