- Home /
Move Player With Capsule Collider
Hello Unity3D.I have a problem with my CharacterController.The problem is when i add for the to opponent or my character.My character moves but the charactercontroller doesn't move to the new spot that its suppose to move to.For example.When i throw a fireball at the opponent the fireball moves the opponent but it doesn't move to the new vector that it suppose to move to.Is there a way that i can push the charactercontroller to the new vector and it stays to the new vector?Or is there a way that i can make my characters move around using the capsule collider?If anyone knows how i can do this.Can you please tell me how?Sorry if this question makes no sense....
Also Heres the script if anyone needs it
#pragma strict
var Run:AudioClip;
var rotationSpeed : float = 10;
var walkSpeed : float = 7;
var body : Transform;
private var yRot: float;
function Update () {
var Controller : CharacterController = GetComponent(CharacterController);
var vertical : Vector3 = transform.TransformDirection(Vector3.forward);
var horizontal : Vector3 = transform.TransformDirection(Vector3.right);
var height : Vector3 = transform.TransformDirection(Vector3.up);
if(Input.GetAxis("Vertical")||Input.GetAxis("Horizontal")){
if (!animation.IsPlaying("Jump"))
if (!animation.IsPlaying("Jump"))
if(!animation.IsPlaying("Reverse_Crescent"))
if(!animation.IsPlaying("Crescent"))
if(!animation.IsPlaying("Spinning_back_kick"))
if(!animation.IsPlaying("Spinning_back_kick2"))
if(!animation.IsPlaying("Jump_Spinning_Back_Kick"))
if(!animation.IsPlaying("Astral_Ball"))
if(!animation.IsPlaying("Hit1"))
if(!animation.IsPlaying("Are_You_Ready_"))
if(!animation.IsPlaying("Kick_Combo"))
if(!animation.IsPlaying("para_kick"))
if(!animation.IsPlaying("Aerial_Cartwhell"))
if(!animation.IsPlaying("Aerial_Cartwhell_Reverse"))
if(!animation.IsPlaying("Snap_Kick"))
if(!animation.IsPlaying("Thrust_Kick_2"))
if(!animation.IsPlaying("Teleport"))
animation.CrossFade("Run2");
animation["Run2"].speed = walkSpeed/100;
Controller.Move((vertical * (walkSpeed * Input.GetAxis("Vertical"))) * Time.deltaTime);
Controller.Move((horizontal * (walkSpeed * Input.GetAxis("Horizontal"))) * Time.deltaTime);
audio.Play();
}else{
if (!animation.IsPlaying("Jump"))
if(!animation.IsPlaying("Wing_Chun_Punch"))
if(!animation.IsPlaying("Palm1"))
if(!animation.IsPlaying("Palm2"))
if(!animation.IsPlaying("palm3"))
if(!animation.IsPlaying("BoeTon_Pause"))
if(!animation.IsPlaying("Hit1"))
if(!animation.IsPlaying("Hit1_Reverse"))
if(!animation.IsPlaying("Hit_Stomach"))
if(!animation.IsPlaying("Hit_Flying"))
if(!animation.IsPlaying("Oh_Hell_To_The_Fuck_Nah_"))
if(!animation.IsPlaying("Mana_Barrage"))
if(!animation.IsPlaying("Teleport"))
if(!animation.IsPlaying("Stand_Air_Hit_back"))
if(!animation.IsPlaying("Shinzuroken_End2"))
if(!animation.IsPlaying("Shinzuroken_End"))
if(!animation.IsPlaying("Violets_Bicycle_Kick_Hit_Part_One"))
if(!animation.IsPlaying("Violets_Bicycle_Kick_Hit_Part_Two"))
if(!animation.IsPlaying("Air_Hit_Going_Up"))
if(!animation.IsPlaying("Shinzuroken_Middle"))
if(!animation.IsPlaying("Shinzuroken_Start"))
if(!animation.IsPlaying("Shinzuroken_Hit"))
if(!animation.IsPlaying("blast_attack"))
if(!animation.IsPlaying("Fire_Eruption"))
if(!animation.IsPlaying("Fireball_Attack"))
if(!animation.IsPlaying("BoeTon_Pause2"))
if(!animation.IsPlaying("Berserk"))
if(!animation.IsPlaying("Burn_To_Hell_"))
if(!animation.IsPlaying("Burn_To_Hell_Part_2"))
if(!animation.IsPlaying("Fire_Imp_Summon"))
if(!animation.IsPlaying("Fire_fury"))
if(!animation.IsPlaying("Gigantic_FireBall_Part_2"))
if(!animation.IsPlaying("Holy_Roar_Hit_Animation"))
if(!animation.IsPlaying("Berserk_Part_2"))
if(!animation.IsPlaying("Fast_Jab"))
if(!animation.IsPlaying("Fast_Jab_2"))
if(!animation.IsPlaying("Fast_Jab_3"))
if(!animation.IsPlaying("Fast_Jab_4"))
if(!animation.IsPlaying("Fast_Jab_5"))
if(!animation.IsPlaying("Flaming_Back_Kick"))
if(!animation.IsPlaying("Flaming_Back_Kick_2"))
if(!animation.IsPlaying("Flaming_Back_Kick_3"))
if(!animation.IsPlaying("Kick_Combo_4"))
if(!animation.IsPlaying("Kick_Combo_3"))
if(!animation.IsPlaying("Kick_Combo_2"))
if(!animation.IsPlaying("Kick_Combo_1"))
if(!animation.IsPlaying("Elbow_Hit_2"))
if(!animation.IsPlaying("Boetons_Stunner"))
if(!animation.IsPlaying("Boetons_Launcher"))
if(!animation.IsPlaying("Rising_knee"))
if(!animation.IsPlaying("Assassin_s_Greeting_Hit_1"))
if(!animation.IsPlaying("Assassin_s_Greeting_Hit_2"))
if(!animation.IsPlaying("Assassin_s_Greeting_Hit_3"))
if(!animation.IsPlaying("Assassin_s_Greeting_Hit_4"))
if(!animation.IsPlaying("Assassin_s_Greeting_Hit_5"))
if(!animation.IsPlaying("Assassin_s_Greeting_Hit_6"))
if(!animation.IsPlaying("Assassins_Greeting_Part_7_Hit"))
if(!animation.IsPlaying("Assassins_Greeting_Part_8_Hit"))
animation.CrossFade("Stance_White_Fang");
animation["Stance_White_Fang"].speed = 0.5;
}
}
function LateUpdate(){
// Rotate the Character to match the direction he/she is going
if(Input.GetAxis("Vertical") == 0){
if(Input.GetAxis("Horizontal") > 0){
body.localEulerAngles.y = 90;//Right sideways running
}else if(Input.GetAxis("Horizontal") < 0){
body.localEulerAngles.y = 270;//Left sideways running
}
}else if(Input.GetAxis("Vertical") > 0){
if(Input.GetAxis("Horizontal") > 0){
body.localEulerAngles.y = -270;
}else if(Input.GetAxis("Horizontal") < 0){
body.localEulerAngles.y = -90;
}
}else if(Input.GetAxis("Vertical") < 0){
if(Input.GetAxis("Horizontal") == 0){
body.localEulerAngles.y = -180;
}else if(Input.GetAxis("Horizontal") > 0){
body.localEulerAngles.y = -180;
}else if(Input.GetAxis("Horizontal") < 0){
body.localEulerAngles.y = -180;
}
}
}
Answer by XinJinXiang · Mar 26, 2015 at 03:23 PM
Have you checked static for your gameobject?
No I Do Not have static checked.But is there a way that i can make my character move with this script with a capsule collider ins$$anonymous$$d of a charactercontroller?
Yeah! You can do it. But you should checked rigidbody freeze rotation. Then it will work fine.
Sorry that this is late....but i have checked it and the capsule collider still doesn't move is there any other way?like,for example.Do i need to change anything in the script or do i need to change the character gravity or do i need to change my animation speed?