I have created a script that removes gaps between moving platforms on my 2D sidescroller game by checking for another platform infront of the platform with the script and then aligning itself to this platform.
The script works perfectly as planned in the unity editor and on PC standalone, but when I put the game onto my android phone, there are gaps and it runs as if the script doesn’t even exist.
There are also no errors whatsoever on PC or android
Here is my script:
using UnityEngine;
using System.Collections;
public class CheckPos : MonoBehaviour {
public Transform _alignTo = null;
public bool _align = false;
Transform myTransform;
void Start ()
{
myTransform = transform;
}
void Update()
{
myTransform.position = transform.parent.position;
}
void OnTriggerEnter(Collider other)
{
if(other.tag == "Environment" && _align == true){
_alignTo = other.transform;
Align();
}
}
void OnTriggerExit ()
{
_alignTo = null;
}
public void Align()
{
//yield return new WaitForSeconds(0.1f);
myTransform.parent.position = _alignTo.transform.position + new Vector3(1f, 0f, 0f);
}
}
UPDATE:
I have built a standalone PC version of the game with better debugging. It seems I have the same problem as with android on pc standalone as well.
Unfortunately the errors are fairly vague so I can’t pinpoint the problem… any ideas?
