Z
Z
Z_programmer2021-06-16 21:27:36
Unity
Z_programmer, 2021-06-16 21:27:36

Character falls at a very slow rate in Unity. How to fix?

I have a problem here related to character programming in Unity. In short, I created a regular sprite with a wall texture, added Rigid Body 2D to it (everything is set to the standard), Box Collider 2D (everything is set to the standard too). The sprite falls at normal speed. But for some reason, when I add a script to it, it starts to fall at an incredibly low speed, although there seems to be nothing like that in the script. I don't know how to fix it. Need help.
Here is the script itself:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class monster_boy_settings : MonoBehaviour
{
  public float movespeed;
  public float addForce;
  public Rigidbody2D rb;
    void Update()
    {
        rb.velocity = new Vector2(Input.GetAxis("Horizontal") * movespeed, 0);
        if (Input.GetKeyDown(KeyCode.W))
        {
            rb.AddForce(Vector2.up * addForce,ForceMode2D.Impulse);
        }
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lipovnik, 2021-06-17
@Lipovnik

In update, the speed in y is constantly equal to 0, so it does not fall.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question