- Home /
Splitscreen, double player touch follow finger working. But have a bug
Hi, After loads of hours of trying complex scripts. I have managed to get one realy simple to work. I use same script for both players, just different screen.width (><). And it works good. But if right player touches first it gets messy.. how if the scripts are totaly same? no matter what combination.
Here is my script:
using UnityEngine; using System.Collections;
public class TouchP1 : MonoBehaviour {
void Update () {
if (Input.touchCount == 1) {
Touch touch = Input.GetTouch(0);
if (touch.position.x < Screen.width/2)
{
if (touch.phase == TouchPhase.Stationary || touch.phase == TouchPhase.Moved) {
Vector3 touchPosition = Camera.main.ScreenToWorldPoint(new Vector3(touch.position.x, touch.position.y, 10));
transform.position = touchPosition ;
}
}
}
else if (Input.touchCount == 2) {
Touch touch = Input.GetTouch(1);
if (touch.position.x < Screen.width/2)
{
if (touch.phase == TouchPhase.Stationary || touch.phase == TouchPhase.Moved) {
Vector3 touchPosition = Camera.main.ScreenToWorldPoint(new Vector3(touch.position.x, touch.position.y, 10));
transform.position = touchPosition ;
}
}
}
}
I tried to do the same thing for making a side that moves the player and a side that moves the player camera and I have the same problem. The other problem is that I can't use the two at the same time.
Your answer
Follow this Question
Related Questions
Split screen in half - Touch Controls 3 Answers
Multiple Touch Drag iOS 0 Answers
Mobile Multiplayer touch controls 0 Answers
Moving the camera on a touch imput 0 Answers