Answer the question
In order to leave comments, you need to log in
How to make the GameObject follow the cursor without offset?
There is a code
void Update()
{
//получить текущие координаты мыши на экране из Input
Vector3 mousePos2D = Input.mousePosition;
//координата Z камеры определяет, как далеко в трехмерном пространстве находится указатель мыши
mousePos2D.z = -Camera.main.transform.position.z;
//преобразовать точку на двухмерной плоскости экрана в трехмерные кординаты игры
Vector3 mousePos3D = Camera.main.ScreenToWorldPoint(mousePos2D);
//переместить корзину вдоль оси X в координату X указателя мыши
Vector3 pos = this.transform.position;
pos.x = mousePos2D.x;
this.transform.position = pos;
}
Answer the question
In order to leave comments, you need to log in
Displacement - do I understand jamming? When the mouse moves and the object stays in place?
Then you need more frames per second
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question