I’m a beginner at unity so I don’t have much experience. I have made a smash script and I’m trying to make it so that the character’s velocity doesn’t carry through (If you smash while going up in a jump your force upwards stays and you rise upwards after you smash downwards)
This is my code
void Update () {
CharacterController controller = GetComponent<CharacterController>();
if(Input.GetKeyDown(KeyCode.X)){
controller.Move(Vector3.down * Time.deltaTime * speed);
controller.velocity.Set(0,0,0);
}
}
controller.velocity is not used for moving the controller, it’s only used to see how fast the controller is moving based on it’s position now and it’s position last frame.
if you want your character to stop moving set speed to 0 so that when you use controller.Move(Vector3.down * Time.deltaTime * speed) it doesn’t move at all.
As far as a specific solution to the functionality you are trying to achieve I’m afraid you’re gonna have to explain the issue a bit clearer. Maybe add a drawing or give us an example of the mechanic in another game.