Simplifying Pins architecture fails on Unity 5.5

I was facing the same child-collider issue when trying the challenge myself, so it was relieving to see that - apparently - it is possible to put all the components on the Pin GameObject. Yet, I have tried the same exact steps in Unity 5.5 - and also tried other - and it ruins the Pin. First, if I copy the components from Pin_Render to the parent and remove the child, the pin is not rendered at all. Invisible. Second, if I move the Pin_Collider components and remove the child, the pin behaves strangely. It rotates when idle and react strangely with gravity.
Did anyone stumbled upon this in previous versions and managed to work around it?

I don’t think your issue lies with Unity. I encountered the same problem, however I believe it was a
Blender export / scaling difference. Our parent pin has a transform scale of 1, while the collider and render children have a transform scale of 100. Thus, when moving the collider and renderer components off the children and onto the parent pin, they adopt the parent pin’s transform scale and are 100 times smaller. So this is how you do it: you either add the components onto the parent anew and then scale by 100, or you get the children off the parent, scale the parent by 100 units and then paste the components.

2 Likes

I found a way to not move any components at all using script.

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class PinSetter : MonoBehaviour {
public Text StandingDisplay;

private bool BallEnteredBox = false;

void Update () {
	StandingDisplay.text = "Pins Standing: " + CountStanding ().ToString ();
}

int CountStanding () {
	int Standing = 0;

	foreach (Pin _Pin in GameObject.FindObjectsOfType<Pin>()) {
		if (_Pin.IsStanding ()) {
			Standing++;
		}
	}

	return Standing;
}

void OnTriggerEnter (Collider Other) {
	GameObject OtherObj = Other.gameObject;

	if (OtherObj.GetComponent<Ball> ()) {
		Debug.Log ("Triggered!");
		BallEnteredBox = true;
		StandingDisplay.color = Color.red;
	}
}

void OnTriggerExit (Collider Other) {
	GameObject OtherObj = Other.gameObject;

	if (OtherObj.GetComponentInParent<Pin> ()) {
		Debug.Log ("Not triggered!");
		Destroy (OtherObj.transform.parent.gameObject);
	    }
    }
}

There was a simple error in the code in the video. He used GetComponentsInParent instead of GetComponentInParent. There was an unwanted “s” that screwed everything up. At the end, I found the parent with a simple piece of code (OtherObj.transform.parent.gameObject) and destroyed it. Everything worked.

4 Likes

Yes, I did this too and I think that this works best. No mod to pins required!

This worked great Thanks

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms