N
N
NitroFuNyx2020-06-30 17:59:37
Unity
NitroFuNyx, 2020-06-30 17:59:37

How to control the character with the mouse?

I'm trying to implement object control with the mouse. It is desirable that when you click on any point of the screen, the reading of where the finger (cursor) stretches to the left / right starts from this, the movement parameter changes in the same direction. I hope I made it as clear as possible :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Z
zZaKko, 2020-06-30
@NitroFuNyx

I did the same with GetAxis. You can look at the documentation on the Internet because there is really a lot of it. The easiest way:

void Update(){
if(Input.GetKey(KeyCode.Mouse0))//При зажатие ЛКП выполняеться код
this.transform.position += new Vector3(1f * Input.GetAxis("Mouse X"),0f,0f);//Обьект по вектору х сменивает свою позицию относительно того, куда была дернута мыщь по осе x
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question