Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force should not be applied and then reduce manually #291

Open
Segelzwerg opened this issue May 22, 2020 · 0 comments · Fixed by #292
Open

Force should not be applied and then reduce manually #291

Segelzwerg opened this issue May 22, 2020 · 0 comments · Fixed by #292
Labels
minor rework minor overhaul

Comments

@Segelzwerg
Copy link
Collaborator

velocity *= speed;
velocity.y = 0;
_rigidbody.AddForce(velocity, ForceMode.Impulse);
// make sure, that the player is not able to be faster then the momentarily speed level is allowing him to be
velocity = _rigidbody.velocity;
velocity.y = 0;
velocity = velocity.normalized * Mathf.Clamp(velocity.magnitude, 0, speed);
velocity.y = _rigidbody.velocity.y;
_rigidbody.velocity = velocity;

@Segelzwerg Segelzwerg added the minor rework minor overhaul label May 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor rework minor overhaul
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant