V
V
Vladislav Kapralov2019-01-04 15:51:36
C++ / C#
Vladislav Kapralov, 2019-01-04 15:51:36

[Unity] Object movement. What to change?

5c2f56a6da4b1560872499.gifI am digging with the movement of the main square (player). The internet is full of tutorials, but they are either for 3D projects or the movement is smooth. I need the square to move a certain distance with each keystroke (as in the GIF).
I experimented with "transform" but didn't get anything.
Code: Teleports an object to a certain point, but does not move it. Experimented a bit with "transform.translate" but no success. I would like to know: "What code is responsible for object displacement?" or "What should be written in brackets so that the coordinates are added to the original ones, and not completely changed?" My problem is that I do not read special educational books, but I learn by doing. For this reason I use "player.transform.position = new Vector2 (+4, 0);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2019-01-04
@Zorexo

player.transform.position = player.transform.position + new Vector2 (+4, 0);

whether?
It's too early for you to make games if such problems arise.
no difference for movement.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question