- Home /
Question by
bileczakos · Apr 11 at 01:24 PM ·
2d2d game2d-physics
My character is going too fast and I don't know what to do.,How do I make my character not go that fast?
I wanna learn game developing and decided to go with unity. I wanna make game wich is kindind simular to flappy bird but u can go to both directions. The only problem with it is that it goes too fast. I tried lowering the horisontalforce but than it only moves slightly. I tought maybe a speedlimit would help but I don't know how to do it. Here is my movement script
public float horisontalForce = 0.6f;
public float verticalForce = 0.4f;
public float maxSpeed = 10f;
float jumpDirection;
void Start()
{
rb = gameObject.GetComponent<Rigidbody2D>();
}
void Update()
{
jumpDirection = Input.GetAxisRaw("Horizontal");
}
void FixedUpdate()
{
if (jumpDirection < -0.1f || jumpDirection > 0.1f)
{
rb.AddForce(new Vector2 (jumpDirection*horisontalForce,verticalForce ),ForceMode2D.Impulse);
}
}`
Comment
Answer by Spip5 · Apr 11 at 08:39 PM
Have you tried changing the ForceMode2D.Impulse to ForceMode2D.Force ?
Impulse is usually used for impacts, explosions, or instant max speed needs (such as projectiles). Force modes suits constant forces much better.
Your answer
![](https://koobas.hobune.stream/wayback/20220613055201im_/https://answers.unity.com/themes/thub/images/avi.jpg)