Answer the question
In order to leave comments, you need to log in
How to block movement along Y?
How to block the movement of an object along Y in C#?
In this script -
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MovePlayer : MonoBehaviour
{
public Transform player;
public static float speed= 10f;
void Start()
{
speed = 10f;
}
public float distance = 10f;
void OnMouseDrag()
{
Vector3 mousePosition = new Vector3(Input.mousePosition.x, Input.mousePosition.y, distance); // переменной записываються координаты мыши по иксу и игрику
Vector3 objPosition = Camera.main.ScreenToWorldPoint(mousePosition); // переменной - объекту присваиваеться переменная с координатами мыши
transform.position = objPosition; // и собственно объекту записываються координаты
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question