I have a bizzare problem; whenever I move this ship, it seems that it's "size" increases exponentially, and then parts of it disappear.

Hi all,

I have a very bizarre problem. I am currently trying to create a spaceship, which is made out of smaller basic models, such as basic “hull” cubes, or triangular wedges.

My currently architecture is that I tie all of these different basic models into a single spaceship by first positioning them in the shape of a spaceship, and then creating a parent empty object which I put all of the basic models under.

Then, for some basic movement, I add this script to the empty game object:

#pragma strict

function Start () 
{

}

function Update () 
{
	if(Input.GetKey("w"))
	{
		transform.position.x = transform.position.x + Time.deltaTime * 10;
	}
	else if(Input.GetKey("s"))
	{
		transform.position.x = transform.position.x - Time.deltaTime * 10;
	}
	else if(Input.GetKey("a"))
	{
		transform.position.z = transform.position.z + Time.deltaTime * 10;
	}
	else if(Input.GetKey("d"))
	{
		transform.position.z = transform.position.z - Time.deltaTime * 10;
	}
	else if(Input.GetKey("up"))
	{
		transform.position.y = transform.position.y + Time.deltaTime * 10;
	}
	else if(Input.GetKey("down"))
	{
		transform.position.y = transform.position.y - Time.deltaTime * 10;
	}
}

The problem that I am experiencing is that although the movement itself seems to work fine, the “world dimensions” of the empty ship object increases exponentially- to ridiculous sizes- and as this occurs, random basic models seem to disappear (or sometimes the entire ship except for a few random models).

I honestly have no idea why this is occurring, or how I could fix it. Does anyone else have any ideas?

P.S. Here is the script I put in the “Editor” folder which shows me the “world dimensions” in the inspector:

// put me in /Assets/Editors/PrintSelectionSize.js
 
@CustomEditor(GameObject)
class PrintSelectionSize extends Editor {
	function OnInspectorGUI() {
		var first = true;
		var bounds : Bounds;
		var renderers = Selection.GetFiltered(Renderer, SelectionMode.Deep);
	   
		for (var r : Renderer in renderers) {
			if (first) {
				bounds = r.bounds;
			} else {
				bounds.Encapsulate(r.bounds);
			}
			first = false;
		}
	   
		EditorGUILayout.BeginHorizontal();
		EditorGUILayout.LabelField("World Dimensions", bounds.size.ToString());
		EditorGUILayout.EndHorizontal();
	}
}

Also, here are some [screenshots][1]
[1]: Screenshots of the Bizarre Problem - Album on Imgur

My guess is because you are doing this

transform.position.z = transform.position.z + Time.deltaTime * 10;

which is multiplying the whole sum which increases with each movement

try this : transform.position.z = transform.position.z + (Time.deltaTime * 10);