Log in or register to post comments

Simple object transform (via script) not working in iOS build

April 30, 2018 - 7:00pm #1

I'm new to Vuforia and have come upon a frustrating issue. I am building a city model with a simple train (just a cube right now) that runs along a track. This is the script I use to make it move (using waypoints):

using System.Collections;

using Vuforia;

using System.Collections.Generic;

using UnityEngine;

public class trainmove : MonoBehaviour {

public Transform[] target;

    public float speed;

private int current;

    void Update()

    {

        if (transform.position != target[current].position)

        {

                Vector3 pos = Vector3.MoveTowards(transform.position, target[current].position, speed * Time.deltaTime);

                GetComponent<Rigidbody>().MovePosition(pos);

     

        }

        else {

            current = (current + 1) % target.Length;

          

        }

}

 

When I play in the Unity game mode window the city and train track the target and the train moves around the model as it should, but when I build to iOS the train is completely still. Can someone help me figure out how to get the train to move in the iOS app as well?

 

Thank you very much!

Log in or register to post comments