Instantiating an object to the location of child of another object.

I have a number of different platform Prefabs, and each has two empty objects(PointA and PointB) as childs, which are located at each end of the platforms. I tried to Instantiate a platform to PointB of another platform, but it doesn’t seem to instantiate at the correct location.Please forgive my ignorance, as I’m still new at this.
Here’s what my code looks like:
public class PlatformSpawn : MonoBehaviour {

	public Transform [] platforms;
	public int platformNumbers = 0;
	private Vector3 nextSpawnLocation;
	private Transform currentPlatform;
	private Transform nextPlatform;

	void Start () {

		if (platformNumbers < 3) {
			Invoke ("Spawn",0f);
		}
	}
	
	//Spawning Function
	void Spawn () {
		if (platformNumbers == 0) {
			currentPlatform = platforms [Random.Range (0, platforms.Length)];
			nextPlatform = platforms [Random.Range (0, platforms.Length)];
			Instantiate (currentPlatform, new Vector3 (0f, 0f, 0f), Quaternion.identity);
			platformNumbers++;
			nextSpawnLocation = currentPlatform.FindChild ("PointB").transform.position;
			Instantiate (nextPlatform, nextSpawnLocation + nextPlatform.transform.position - nextPlatform.FindChild("PointA").position, Quaternion.identity);
			platformNumbers++;
			print (nextSpawnLocation);
			print (currentPlatform.FindChild ("PointB").transform.position);
		}
	}
}

Looks like you don’t know about localPosition, and the math is backwards?

This (edited to length) line in Instantiate:

nextSpawnLocation+nextPlatform.position-nextPlatform.FindChild("PointA").position

looks like you’re trying to use PointA as an offset. “Spawn at nextLocation, but shifted by PointA.” An easier way to get that is to use localPosition instead of position. Otherwise, the math seems backwards. Shouldn’t it be pointA-platformPosition?

If things rotate, then the two are different. LocalPosition is in the parent’s local coords, whereas child.pos-parent.pos is always in global coords. But only if parents are rotated, does this matter.

I’m also a little confused by “trying to Instantiate at point B.” You can just use pointB.position directly. Even for children, position is the actual, world position. LocalPosition is the one that changes up if you’re a child. But if that was what you really wanted, you wouldn’t have used all that math?

After a bit of testing, I have found the answer. The reason why the platforms are instantiating at a spot different than what I intended was because I thought the parentObeject’s position is the centre point of the parentObject and all its children (that’s what it shows in the game scene when I select the parentObject). When actually, the position of the parentObject is basically the centre point of just the parentObject by itself (without the children). Forgive my naivety.