Answer the question
In order to leave comments, you need to log in
Why does an object move by inertia?
I have control, for some reason the object flies further by inertia, how to fix it?
In Rigidbody 2D gravity is set to 0.
Here is the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class object : MonoBehaviour
{
public int velocity = 1;
private Rigidbody2D rb;
void Awake()
{
rb = GetComponent<Rigidbody2D>();
}
void Update()
{
if (Input.GetKey("space"))
rb.velocity = Vector3.down* velocity;
if (Input.GetMouseButtonDown(0))
rb.velocity = Vector3.up * velocity;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question