V
V
VortDyn2020-06-21 16:01:28
2D
VortDyn, 2020-06-21 16:01:28

2D Character stuck on something?

Using collider 2d, move object with rb2d.velocity
How it works: https://youtu.be/L2msz6WTSmU

public Rigidbody2D rb;
    public float maxSpeed;

    private void Start()
    {
        rb = GetComponent<Rigidbody2D>();
    }
    void Update()
    {
        float move = Input.GetAxis("Horizontal");


        rb.velocity = new Vector2(move * maxSpeed, rb.velocity.y);
    }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
DanielMcRon, 2020-06-22
@VortDyn

Most likely, there are joints between the tiles and they form a ledge, if you take a capsule collider, it passes them well, while the square one rests against them

S
skroliks, 2022-04-18
@skroliks

Here I have a similar situation, only braking (getting stuck) occurs exactly when the character starts to move the object: either it normally moves far in a straight line, then it gets stuck every couple of segments or more often and it’s not clear by what principle in general and how .. The character has a capsule collider. The ground (environment) is made with tiles and everything is perfectly even there. The subject changed the collider from square to capsule too, but the problem has not disappeared anywhere - help me figure it out ((

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question