Я хочу создать путь предварительного просмотра прицела для мяча с помощью сенсорного ввода, и я пробую его и создал только одно направление, но я хочу создать с дугой 3 типа.
targetи исходное положение являются фиксированными, но изменение пути кривой дуги зависит от элемента управления
Если пользователь проведет пальцем по правой стороне, поэтому нарисуйте начало пути к цели с дугой, а кривую дуги с правой стороной x =10
Если пользователь проведет пальцем по левой стороне, то нарисуйте точку начала координат до цели с помощью дуги и кривой дуги с левой стороны x = -10
если пользовательв центре, поэтому нарисуйте начало пути к цели с помощью дуги и кривой дуги с X = 0
void Update()
{
if (Application.isMobilePlatform)
{
// If pressed with one finger
if (Input.GetMouseButtonDown(0))
{
pressX = Input.touches[0].position.x;
pressY = Input.touches[0].position.y;
}
else if (Input.GetMouseButtonUp(0))
{
pressX = 0;
pressY = 0;
}
if (pressX != 0)
{
float currentX = Input.touches[0].position.x;
if (currentX < pressX)
XValue = (currentX - pressX) / 100;
else if (currentX > pressX)
XValue = (currentX - pressX) / 100;
if (target.transform.position.y < 45.0f)
{
TargetPosition = target.transform.position;
print("YValue : " + YValue);
TargetPosition.x += XValue;
TargetPosition.y += YValue;
target.transform.position = TargetPosition;
}
else
{
TargetPosition = target.transform.position;
print("YValue : " + YValue);
TargetPosition.x += XValue;
TargetPosition.y += YValue;
if (target.transform.position.y > 45.0f)
TargetPosition.y = 45;
target.transform.position = TargetPosition;
}
DrawPath();
}
if (pressY != 0)
{
float currentY = Input.mousePosition.y;
if (currentY < pressY)
YValue = (currentY - pressY) / 100;
else if (currentY > pressY)
YValue = (currentY - pressY) / 100;
if (target.transform.position.y < 45.0f)
{
TargetPosition = target.transform.position;
print("YValue : " + YValue);
TargetPosition.x += XValue;
TargetPosition.y += YValue;
target.transform.position = TargetPosition;
}
else
{
TargetPosition = target.transform.position;
print("YValue : " + YValue);
TargetPosition.x += XValue;
TargetPosition.y += YValue;
if (target.transform.position.y > 45.0f)
TargetPosition.y = 45;
target.transform.position = TargetPosition;
}
DrawPath();
}
}
else
{
if (Input.GetMouseButtonDown(0))
{
pressX = Input.mousePosition.x;
pressY = Input.mousePosition.y;
}
else if (Input.GetMouseButtonUp(0))
pressX = 0;
if (pressX != 0)
{
float currentX = Input.mousePosition.x;
float currentY = Input.mousePosition.y;
if (currentX < pressX)
XValue = (currentX - pressX) / 100;
else if (currentX > pressX)
XValue = (currentX - pressX) / 100;
if (currentY < pressY)
YValue = (currentY - pressY) / 100;
else if (currentY > pressY)
YValue = (currentY - pressY) / 100;
if (target.transform.position.y < 45.0f )
{
TargetPosition = target.transform.position;
print("YValue : " + YValue);
TargetPosition.x += XValue;
TargetPosition.y += YValue;
target.transform.position = TargetPosition;
//target.transform.position = new Vector3(target.transform.position.x, target.transform.position.y + YValue, target.transform.position.z);
}
else
{
TargetPosition = target.transform.position;
print("YValue : " + YValue);
TargetPosition.x += XValue;
TargetPosition.y += YValue;
if (target.transform.position.y > 45.0f)
TargetPosition.y = 45;
target.transform.position = TargetPosition;
}
DrawPath();
}
else
{
}
}
if (Input.GetMouseButtonUp(0))
{
print("Mouse Click Call");
//Rigidbody obj = Instantiate(ball, transform.position, Quaternion.identity);
//obj.velocity = Vo;
ball.position = transform.position;
Physics.gravity = Vector3.up * gravity;
ball.useGravity = true;
ball.velocity = CalculateLaunchData().initialVelocity;
}
}
я создал как:
![enter image description here](https://i.stack.imgur.com/teIO1.jpg)
И я хочу Нравится: Справочное видео