M
M
My joy2017-01-29 22:04:41
Unity
My joy, 2017-01-29 22:04:41

Smooth change of object coordinates in unity?

Good evening comrade friends.
I move left to right and jump by clicking on 3 corresponding buttons. everything works with the jump, but the movement is instantaneous. How to make it move smoothly and not "teleport"?
( btnLeftClick , btnRightClick )

using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using System.Collections;

public class Ball : MonoBehaviour {
...
  void btnTopClick() {
    if(canJump){
      canJump = false;
      rb.AddForce(0, forceConst, 0, ForceMode.Impulse);
    }
  }
  void btnLeftClick() {
    transform.Translate(new Vector3(-5, 0, 0));
  }
  void btnRightClick() {
    transform.Translate(new Vector3(5, 0, 0));
  }
...
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Espleth, 2017-01-29
@t-alexashka

https://habrahabr.ru/post/211472/
From now on, Google and tons of tutorials will help you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question