how do I duplicate an object and have it be in a different position?

I have been watching an endless runner tutorial on YouTube lately, but I am stumped on the part where the platforms are supposed to duplicate and move a little bit to the right so that the player can run endlessly. I however didn’t do my platforms the same way as the guy in the video did his, I made mine in as one big platform that i wanted to use. He made his from 2d squares basically. I didn’t want to do it exactly like he did but every time i use the instantiate code it either duplicates in the exact position. When I did try it his way it would duplicate them correctly and it would move right on the x axis as intended, however the platforms would be tilted 90 degrees when they should be flat. If anyone could help me with this problem i’m having I would gladly appreciate it.

This is how my platforms look and what it does with the script I have for it.

This is the code I wrote for the platforms.

using UnityEngine;
using System.Collections;

public class PlatformGenerator : MonoBehaviour {

	public GameObject thePlatform;
	public Transform generationPoint;
	public float distanceBetween;

	private float platformWidth;

	// Use this for initialization
	void Start () {
		platformWidth = thePlatform.GetComponent<BoxCollider2D> ().size.x;
	// Update is called once per frame
	void Update () {
		if (transform.position.x < generationPoint.position.x) 
			transform.position = new Vector3(transform.position.x + platformWidth + distanceBetween, transform.position.y, transform.position.z);

			Instantiate (thePlatform, transform.position, transform.rotation);



i would make a new variable for transform and store the vector3 in that temporarily like

Transform tempTransform = new Transform();
tempTransform.position = new Vector3(transform.position.x + platformWidth + distanceBetween, transform.position.y, transform.position.z);
tempTransform.RotateAround(transform.position,new Vector3(0,0,1),90);
Instantiate (thePlatform, tempTransform.position, tempTransform.rotation);

or something similar :slight_smile: