- Home /
How to halt all other movement during an attack
I currently have a third person game in which my character can successfully run, jump, sprint and attack. It is an edit of the 3rd person controller script altered to accommodate a simple kick animation when the left mouse button is clicked. The issue is, the kick is meant to be performed while standing still, so if i am moving at all when i decide to kick, the character appears to slide across the ground. Is there any way for me to halt all directional movement for when the character is kicking? If so, can that same principle be used to make it so that the character cannot kick when he is in mid-air?
Any help is much appreciated.
-Foxmonkey104
Answer by Panik.Studios · Aug 22, 2012 at 09:15 PM
I think you need to add constraints... Im not sure how to do this.. I tired looking in the referencesm but perhaps you could do something like
function Update(){
if Input.GetAxisRaw("kick"){
Input.GetAxisRaw("Horizontal") = false;
Input.GetAxisRaw("Vertical") = false;
}
else {
Input.GetAxisRaw("Horizontal") = true;
Input.GetAxisRaw("Vertical") = true;
}
}
Answer by Mander · Aug 22, 2012 at 09:12 PM
yes u can stop ur char from moving. u can make a bool and
if(kickin){
//stop ur movement
animation.Play("kick");
}
or u can place ur movement controllers inside the kicking if
if(!kickin){
//movement controllers
}else if(isGrounded && input.GetButtonDown("Fire1"))
{
kickin= true;
animation.Play("kick");
kickin= false;
}
if u r using character controller. you can make an if statement using isGrounded this way u can kick only if u r on the ground.
How does this solve the character moving though? All this does is telling is to play the kick animation when kicking.. Fox said the kick executes but the character slides.. Not saying this code you've given wont do that, but how is it doing that?
Answer by behzad.robot · Aug 23, 2012 at 05:27 AM
I think This may Help You Stoping Character I've used it for my own script which was not edited version of 3rd Person Controller And the guy was a runner And it answered The character Stops !!
if(Input.GetAxisRaw("kick"))
{
motor.inputMoveDirection = Vector3(0,0,0); //Your Code Here
}
I think This may Help You Stoping Character I've used it for my own script which was not edited version of 3rd Person Controller And the guy was a runner And it answered!! I've Also given this as an answer but i dont have enough karma So it wont be showed to public till a moderator accepts it :(
if(Input.GetAxisRaw("kick"))
{
motor.input$$anonymous$$oveDirection = Vector3(0,0,0);
}