Moving a child object to collide with wall.

Good morning all,

Sorry for the long post.

I have a game where I am generating walls and platforms up the Y axis and I need to make the platforms move left and right randomly. In the image below the green platform is a child object of the frame. I can make the green platform move but it is not colliding with the walls even though I have them collidable in the Physics settings.


My code for the Platforms to spawn and position randomly between the walls is below. (I have two copies of my project, one at work that I work on during lunch and the main one at home) In the code I have OnTriggerEnter for when the platform collides with the wall but it never gives out a value even though I make it debug.log it.

Please could you show me where I’m going wrong. Thanks in advanced

public class MovingPlatform : MonoBehaviour

    private float platformMin = -6.5f;
    private float platformMax = 6.5f;

    void Start()

    public void RadomizePlatforms()
        GameObject[] platforms = GameObject.FindGameObjectsWithTag("PlatformFrame");

        foreach (GameObject platform in platforms)
            Vector3 pos = platform.transform.position;
            pos.x = Random.Range(platformMin, platformMax);
            platform.transform.position = pos;
    void OnColliderEnter (Collider other)
       //tell me what the platform triggered
        Debug.Log("triggered: " +;

I think that it might be the layers that might be causing it but I’m not sure. The walls need to collide with the PlatformFrames and the Slider.

the platforms need to collide with the walls and the player(for now is default.)