I have written very simple application in Unity for Windows Phone.
Aquarium background, bubbles (particle system) and fishes moving from left to right and right to left.
I published app to Windows Phone Store for free and in reports there are many crashes.
Stack trace which can I export:
App: AquariumInPhone
OS version: 8.0
Problem function: Unknown
Exception type: c0000005
30-day crash count: 23
Stack trace:
Frame Image Function Offset
0 ntdll RtlpWaitOnCriticalSection 0x0000007e
1 ntdll RtlpEnterCriticalSectionContended 0x00000060
2 unityplayer 0x002ef5ac
This is very simple application, but crashes
Fishes moving left have code:
using UnityEngine;
public class Fish1 : MonoBehaviour {
float speed = 0.0032f;
Vector3 startPoint;
Vector3 currentPosition;
System.Random r = new System.Random ();
void Start()
{
startPoint = transform.position;
currentPosition = transform.position;
}
void Update ()
{
if (Camera.main.WorldToViewportPoint(transform.position).x < -0.2f)
{
int newY = r.Next(0, 5);
if(r.Next(0, 2) == 0)
newY = -newY;
Vector3 pos = new Vector3(12.0f, (float)newY, 0.0f);
currentPosition = pos;
transform.position = currentPosition;
}
else
{
currentPosition.x--;
transform.position += (currentPosition + startPoint) * speed * Time.deltaTime;
}
}
}
Fishes moving right have code:
using UnityEngine;
public class Fish2 : MonoBehaviour {
float speed = 0.005f;
Vector3 startPoint;
Vector3 currentPosition;
System.Random r = new System.Random ();
void Start()
{
startPoint = transform.position;
currentPosition = transform.position;
}
void Update ()
{
if (Camera.main.WorldToViewportPoint(transform.position).x > 1.2f)
{
int newY = r.Next(0, 5);
if(r.Next(0, 2) == 0)
newY = -newY;
Vector3 pos = new Vector3(-12.0f, (float)newY, 0.0f);
currentPosition = pos;
transform.position = currentPosition;
}
else
{
currentPosition.x++;
transform.position += (currentPosition + startPoint) * speed * Time.deltaTime;
}
}
}
What can be the reason of crash? How can I fix this?
On stackoverflow somebody told me to post my problem here.
Regards, David