K
K
Katya Mirnaya2021-06-08 20:33:42
2D
Katya Mirnaya, 2021-06-08 20:33:42

How to limit a Unity2D character?

In general, I wrote a small toy, but it is so-so.

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

public class Run : MonoBehaviour 
{
  public float speed = 0.01f;

  private void Update()
  {
    transform.position += new Vector3(0, speed, 0) * Input.GetAxis("Vertical");
  }
}

All code.
It is necessary to somehow make a constraint for the character using RigidBody2D and the colliders get twitchy, how could this be fixed?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question