Answer the question
In order to leave comments, you need to log in
How to make a restriction on the movement of an object?
making a game (2D) ran into a problem that the character goes beyond the camera. I want to make it so that he could not go beyond, but I don’t know how to do it :( . here is the script (The character moves with a wave of a swipe)
float Max = 3.51f;
float Min = -3.51f;
public float position ;
public GameObject player;
public void OnBeginDrag(PointerEventData eventData)
{
Vector2 delta = eventData.delta; // пк управление
// Vector2 delta = Input.GetTouch(0).deltaPosition; --- телефон управление
if (Mathf.Abs(delta.y) > Mathf.Abs(delta.x))
{
if (delta.x > 0) player.transform.Translate(0 , 3.50f , 0 ) ;
else player.transform.Translate(0, -3.50f, 0 );
}
}
public void OnDrag(PointerEventData eventData)
{
}
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