Y
Y
yraiv2020-05-19 18:43:00
Unity
yraiv, 2020-05-19 18:43:00

How to implement the movement of the character to the right place?

There is a character. There are 3 towers. it is necessary that by clicking on the area near the tower, the character moves to this tower. Type, the screen is divided into 3 parts and if a person presses on some part, then he throws it there. How to do it? I thought to hang the collider and catch clicks, and then move the character to the place where the click was, but I don’t know how to do it right?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
asysprotri, 2020-05-20
@yraiv

RigidBody rb

void Start():
    rb = get component<RighidBody>

public void тут твой метод():
    if туда куда тебе нужно > posintion.x, position.y:
        rb.velocity = newVector2(posintion.x, position.y - туда куда тебе нужно)
    else:
       rb.velocity = newVector2(posintion.x, position.y + туда куда тебе нужно)

I'm not sure about the spelling

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question