In android i test the "moving touch drag cursor" but is to slow to play teh game like that.
is better whit the pointer following the finger touch,
my question is if i can ofset the pointer to make it follow the finger but offset, a bit more higher than the finger touch so i can see where is the pointer.
thanks
Comments
Try this:
using UnityEngine;
using System.Collections;
using AC;
public class OffsetCursorExample : MonoBehaviour
{
public Vector2 touchOffset;
private void Start ()
{
KickStarter.playerInput.InputMousePositionDelegate = CustomMousePosition;
}
private Vector2 CustomMousePosition (bool cursorIsLocked)
{
#if UNITY_EDITOR
Vector2 touchPosition = Input.mousePosition;
#else
Vector2 touchPosition = Input.GetTouch (0).position;
#endif
return touchPosition + touchOffset;
}
}
Place it in a C# script named OffsetCursorExample and add to a GameObject in your scene. You can tweak the Touch Offset field in its Inspector to choose the size of the offset.
I shall look into addressing this in the next release, but in the meantime you can hack it by opening PlayerInput.cs, and replacing line 423:
mousePosition = Input.GetTouch (0).position;
with:
Vector2 touchOffset = new Vector2 (10f, 0f);
mousePosition = Input.GetTouch (0).position + touchOffset;
And modifiying the "touchOffset" vector values to suit.
public class OffsetCursorExample : MonoBehaviour
{
public Vector2 touchOffset;
private void Start ()
{
KickStarter.playerInput.InputTouchPositionDelegate = CustomTouchPosition;
}
private Vector2 CustomTouchPosition ()
{
Vector2 touchPosition = Input.GetTouch (0).position;
return touchPosition + touchOffset;
}
}
What is it about the script that isn't working? Don't forget to include the "using" lines posted in the first reply.
using System.Collections;
using AC;
public class OffsetCursorExample : MonoBehaviour
{
public Vector2 touchOffset;
private void Start ()
{
KickStarter.playerInput.InputMousePositionDelegate = CustomMousePosition;
}
private Vector2 CustomTouchPosition ()
{
#if UNITY_EDITOR
Vector2 touchPosition = Input.mousePosition;
#else
Vector2 touchPosition = Input.GetTouch (0).position;
#endif
return touchPosition + touchOffset;
}
}
using System.Collections;
using AC;
public class OffsetCursorExample : MonoBehaviour
{
public Vector2 touchOffset;
private void Start ()
{
KickStarter.playerInput.InputMousePositionDelegate = CustomMousePosition;
}
private Vector2 CustomTouchPosition ()
{
#if UNITY_EDITOR
Vector2 touchPosition = Input.mousePosition;
#else
Vector2 touchPosition = Input.GetTouch (0).position;
#endif
return touchPosition + touchOffset;
}
}
Replace the line inside your Start() function with this:
KickStarter.playerInput.InputTouchPositionDelegate = CustomTouchPosition;