V
V
Vladislav Kapralov2019-01-01 21:51:19
C++ / C#
Vladislav Kapralov, 2019-01-01 21:51:19

[Unity] Create an object in the player's place. How to do?

5c2bb6937c2d0674828859.gifI recently started to explore the world of programming. I decided to implement a small 2B project.
As planned: The player controls the square, and there should be a solid wall behind the square.
Example: A square stands on point "B" --> It is moved by one conventional unit
--> Another static square appears on point "B", with the same dimensions.
The controlled square cannot collide with them.
Attached a gif I made for myself. (Ignore the "snakes" in the middle. They should act as other objects colliding with the wall)
Please write the code, and the conditions necessary for the code to work.
I think the code is very simple, but with my knowledge, even such a code is very complex.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Gaydak, 2019-01-01
@Zorexo

Just like answering the question in the title

Instantiate (cubePrefab, playerLastPos, Quaternion.identity);
//cubePrefab - ссфлка на префаб куба)
// playerLastPos - Vector3 - позиция игрока (куба),сохраненная при прошлом вводе

even if you write the code ..
the sky will be of little use to you ..
you need to configure it. it will be necessary to understand and complete it ..
study the little things
GameObject
Instantiate
Prefabs
Input
about the Update method ..
In general, learn the basics .. try to throw at least the simplest option
to control, move the cube ..
And then come here with questions))
about collisions / triggers and physics (if necessary)
about "tell me how you can finish it"
or "what's wrong here"))
good luck.

G
GavriKos, 2019-01-01
@GavriKos

Please write the code, and the conditions necessary for the code to work.

In what currency should the conditions be written?
You freelancing with such requests. They won't write code for you.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question