Hello Guys,
I am working on this platform where when the player jumps on it, it falls down and gets destroyed. but how do i make it respawn back to its initial position because when the player respawns the platform is not there still.
here is my script so far :
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FallingPlatform : MonoBehaviour
{
bool isFalling = false;
float downSpeed = 0;
void OnTriggerEnter(Collider collider)
{
if (collider.gameObject.name == "Player")
{
isFalling = true;
Destroy(gameObject, 10);
}
}
void Update ()
{
if (isFalling)
{
downSpeed += Time.deltaTime / 10;
transform.position = new Vector3(transform.position.x,
transform.position.y - downSpeed,
transform.position.z);
}
}
}
any help would be appreciated.
Thank you