Spawning platform when i press a button

im working on a 2D jump 'n run game. One of the Characters is a platform. I want to add the abillity, that when I press on the A button on my gamepad, he spawns a platform on his position, so the other player can jump on that. I want him to spawn 2 platforms, then the first disappears … I hope you understand.

My code so far:

var speed = 25.0;

function Update () {

var htranslation = Input.GetAxis (“HorizontalP1”) * speed;
var vtranslation = Input.GetAxis(“VerticalP1”) * speed;

htranslation *= Time.deltaTime;
vtranslation *= Time.deltaTime;

transform.Translate (0, 0, htranslation);
transform.Translate (0, vtranslation, 0);

Any ideas? I’m not that grat with js. haha

greetings, T.

One idea (insert within the Update function after everything else):

if (GetButton("/*Insert name of button here!*/"))
private var playerPosition : Vector3 = player.transform.position


AND insert this before the Update function:

private var player : GameObject //Place the player object from the scene here in the inspector.
var platform : GameObject //Place platform prefab here in the inspector.

I think you should be able to modify this if needed