I have to make a game for mobile games in Unity, and I ran into a serious problem: the Input class in Unity is frame dependent. Thus, I cannot get the touch position often enough to make my application smooth; as a result, I get something like just dots in the background that are not interconnected.
I tried to just connect the points found in Unity, and of course my result was exactly the same as the lines. I tried this in the Unity editor with about 180-200 frames per second, and on a mobile phone with 30-50 frames per second it looks even worse. I expect that I need to somehow get the touch positions in the Android or Xcode studio, and only then use them in my C # code in the Unity editor.
Am I thinking of using extern from Unity tools, or is there another easy way to do this directly in Unity? If they are not, and I'm right, can someone give me links to guides / tutorials on how to do this and integrate them with Unity? I have never worked outside of Unity and had no experience integrating external tools with it.
Note. I tried FixedUpdate without any luck - no matter how often I try to get variable positions, it's about how often they are updated; I also tried Event.current.mousePosition (in the unit editor) in the OnGUI method, but that also didn't make any difference.
Update. As I said, I need to get positions more often than the input class gives. It does not update fast enough! This is what I get without tying the dots. The image shows the mousePosition detection frequency of 180-200 fps. On phones it is even slower!
Update: here is my simplified code.
void Draw()
{
currentMousePosition = new Vector2( x, y);
if(currentMousePosition != previousMousePosition)
{
while(currentMousePosition != previousMousePosition)
{
mySprite.texture.SetPixels((int)previousMousePosition.x, (int)previousMousePosition.y, 3,3, myColorArray);
if (currentFrameMousePos.x > previousFrameMousePos.x)
previousFrameMousePos.x++;
if (currentFrameMousePos.x < previousFrameMousePos.x)
previousFrameMousePos.x--;
if (currentFrameMousePos.y > previousFrameMousePos.y)
previousFrameMousePos.y++;
if (currentFrameMousePos.y < previousFrameMousePos.y)
previousFrameMousePos.y--;
}
} else mySprite.texture.SetPixels((int)currentMousePosition.x, (int)currentMousePosition.y, 3,3, myColorArray);
previousMousePosition = currentMousePosition;
}