- Home /
How do I move multiple 3D objects with Android touchscreen?
Hey! I was originally able to move the character with terrible touch controls before but I couldn't move the enemies simultaneously with the character in different directions...
I want to control the enemies into falling hazards. I've searched & searched the web & have not yet found an ideal solution for this. Do you have any examples of games where you can move the character and the enemies?
Note: The commented code at the bottom is the original functional code.
void Update()
{
multiTouchInfo = string.Format("Max tap count: {0}\n", maxTapCount);
if (Input.touchCount > 0)
{
for (int i = 0; i < Input.touchCount; i++)
{
theTouch = Input.GetTouch(i);
multiTouchInfo += string.Format("Touch {0} -Position {1} -Tap Count: {2} -Finger ID: {3}\nRadius: {4} ({5}%)\n",
i, theTouch.position, theTouch.tapCount, theTouch.fingerId, theTouch.radius,
((theTouch.radius / (theTouch.radius + theTouch.radiusVariance)) * 100f).ToString("F1"));
if (theTouch.tapCount > maxTapCount)
{
maxTapCount = theTouch.tapCount;
}
}
}
multiTouchInfoDisplay.text = multiTouchInfo;
/*if (Input.touchCount > 0)
{
//touch = Input.GetTouch(0);
if (touch.phase == TouchPhase.Moved && !CloseToWall())
{
transform.position = new Vector3(
transform.position.x + touch.deltaPosition.x * speedModifier,
transform.position.y,
transform.position.z + touch.deltaPosition.y * speedModifier);
}
}*/
}
Answer by unity_5UuMRw312fOSgQ · Jan 10, 2021 at 02:49 AM
Your game look pretty good! How long have you worked on it? Oh and also if i understand correctly you can make an empty game object with the movement script and attach all the enemies as children, they will all move in the exact same way but they can have different positions. Hope this works for you, let me know.
Your answer
Follow this Question
Related Questions
How to Touch Drag 3D Objects 2 Answers
I need to move an object when touched on an android phone 1 Answer
Using GUI buttons to move a sprite (C#) 2 Answers
GameObject won't jump with touch 1 Answer
The bullet doesn't move correctly 1 Answer