Question by
rorysully · Mar 26, 2020 at 01:59 AM ·
colliderbuild-errormeshcolliderbuild and run
Object position doesnt change in Build but does in Scene/Editor Game
Hello,
I am creating a 3D game that works perfectly when played in unity editor. All scripts run and work as expected and when they are meant to. However, when I build and run the game, certain scripts no longer update object positions.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Teleport : MonoBehaviour
{
public GameObject table;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
GlobalValueTracker.Instance.closeDoorsLoop = false;
/*print(Vector3.Distance(table.transform.position, transform.position));*/
if (Vector3.Distance(table.transform.position, transform.position) < 4) {
GlobalValueTracker.Instance.closeDoorsLoop = true;
if (Vector3.Distance(table.transform.position, transform.position) < 3)
{
transform.position = new Vector3(transform.position.x - 28.8579f, transform.position.y, transform.position.z + 9.28936f);
if (GlobalValueTracker.Instance.nextLoop)
{
GlobalValueTracker.Instance.loopNum++;
GlobalValueTracker.Instance.nextLoop = false;
GlobalValueTracker.Instance.closeLockDoorsLoop = true;
GlobalValueTracker.Instance.played = false;
}
}
}
}
}
In the above script, the transform.position = new Vector3(transform.position.x - 28.8579f, transform.position.y, transform.position.z + 9.28936f); never actually changes the player position like it should. Any ideas why?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612225728im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Blender Models aren't generating mesh colliders! 0 Answers
How to fix Unity 5 Mesh Collider Convex Problems? 1 Answer
Player not moving after build 0 Answers
How to make a bowl? 0 Answers