I’m creating a game called Stick Into It and I just did a build.
The problem happens at levels with buttons, let me explain:
On a build, when you press the button a GameObject moves down but the GameObject moves slower in a build than normally
this is the MoveBoxY script that gets controlled by the Button script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MoveBoxY : MonoBehaviour
{
private Vector3 posStart;
public float posY;
void Start()
{
posStart = transform.position;
}
void Update()
{
transform.position = posStart + new Vector3(0, posY, 0);
}
}
This is the Button script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Button : MonoBehaviour
{
public GameObject parent;
public delegate void Event();
public bool useMoveBoxYScript;
[Tooltip("The 'MoveBoxY' script on a GameObject that will be enabled")]
public MoveBoxY moveBoxYScript;
public bool useRotateBoxZScript;
[Tooltip("The 'RotateBoxZ' script on a GameObject that will be enabled")]
public RotateBoxZ rotateBoxZScript;
private bool pressed;
void OnTriggerEnter2D(Collider2D collidedObj)
{
if (collidedObj.CompareTag("Stick"))
{
parent.GetComponent<Animator>().enabled = true;
if (!pressed)
{
parent.GetComponent<AudioSource>().Play();
pressed = true;
}
if (useMoveBoxYScript)
{
moveBoxYScript.enabled = true;
}
if (useRotateBoxZScript)
{
rotateBoxZScript.enabled = true;
}
}
}
// This is the moving part
void Update()
{
if (useMoveBoxYScript && moveBoxYScript.enabled && moveBoxYScript.posY >= -6.5)
{
moveBoxYScript.posY = moveBoxYScript.posY - 0.01f;
}
if (useRotateBoxZScript && rotateBoxZScript.enabled && rotateBoxZScript.rotZ < 180)
{
rotateBoxZScript.rotZ = rotateBoxZScript.rotZ + 0.5f;
}
}
}
Can someone please help me? I’m using Unity 2020.3.3f1 and the problem only happens in a build.