Best way to save performance on moving colliders?

i’m making a 3d platformer and i wanted to have a number of platforms moving in groups (parented to the moving platform.) however, the physics simulation of so many platforms at once is too much for the iphone to handle. however, i thought since each group is parented to an object anyway, i could put a trigger collider on the parent object and make a script that disabled and enabled the child colliders based on the player character’s proximity, so that only a handful of colliders would actually be physically simulating at once and the iphone could handle it. i was all ready to go with this until it turns out you can’t disable and enable colliders! which… well, maybe there’s a solid reason for it from a developer’s standpoint, but from a user standpoint it’s just asinine. right now the only way i see is to make the collider a separate gameObject and make it active or inactive, but i already have all kinds of code attached to the platforms, and i’ll have to do some really awful messy crap to it to get it to work with this new way. also, will i even get a performance benefit this way? what are the memory/performance implications of making a gameObject active and inactive? is there any other way? ugh. pretty disappointed with the unity API right now.

I don’t know what the performance implications of activating / deactivating gameobjects are but that seems like the simplest solution.

As an alternative, you can use enabled / disabled to turn certain GO components (including scripts) off and on when needed.

I’ve had some weird issues deactivating colliders in non-iPhone Unity. You can also remove and add colliders to objects on the fly, which is another option to check performance on.

what kind of “weird issues” exactly?

adding and removing colliders would cause garbage collection to run a lot more often, as far as i understand.

Never move a static collider; instead, use kinematic rigidbodies.

alright, looks like that should improve performance although i want to have a whole lot of stuff rotating so i may still have to trigger collider objects on and off but thanks.

trying to write a script for the proximity trigger to turn on and off the collider/rigidbody objects, but i’m having a hard time accesssing these “grandchildren” as it were, i can only get the children (which are the rendered mesh and logic of the platform.) tried many different variations on the start() code but none worked. what should i do differently here in order to put into an array and iterate over the children of the children?

using UnityEngine;
using System.Collections;

public class MovingPlatformColliderTriggerer : MonoBehaviour {

	Transform[] listOfPlatforms;
	GameObject[] listOfChildren;
	
	void Start () {
		
		listOfPlatforms = new Transform[transform.childCount];
		int i = 0;
		foreach (Transform child in transform) {
			listOfPlatforms[i] = child.transform;
			i++;
		} 
		
		listOfChildren = new GameObject[transform.childCount];
		int n = 0;
		foreach (Transform colliderChild in listOfPlatforms) {
			listOfChildren[n] = colliderChild.gameObject;
			n++;
		}
		
		foreach (GameObject colliderChild in listOfChildren) {
			colliderChild.active = false;
		}
	}
	
	void OnTriggerEnter (Collider other) {
		if (other.gameObject.tag == "Player") {
			foreach (GameObject colliderChild in listOfChildren) {
				colliderChild.active = true;
			}
		}
	}
	
	void OnTriggerExit (Collider other) {
		if (other.gameObject.tag == "Player") {
			foreach (GameObject colliderChild in listOfChildren) {
				colliderChild.active = false;
			}
		}
	}
}

Does gameObject.SetActiveRecursively help you here?