Hello,
I’m trying to write a script which creates a platform and over short period of time moves the platform into position above. But I can get it working properly: the platform instantiates only on start position and doesn’t move at all. Thanks for the help.
using UnityEngine;
using System.Collections;
public class GroundCreator : MonoBehaviour {
public GameObject[] ground;
public Transform startpoint;
public Transform endpoint;
public bool detector;
public float time = 1f;
void Start()
{
detector = false;
}
void OnTriggerEnter2D (Collider2D other)
{
if(other.tag == "Player")
{
detector = true;
}
}
void Update()
{
if(detector == true)
{
int i = Random.Range(0, ground.Length);
GameObject groundInstance = Instantiate(ground*, startpoint.position, startpoint.rotation) as GameObject;*
_ groundInstance.transform.position = Vector3.Slerp(startpoint.position, endpoint.position, time * Time.deltaTime);_
-
Destroy(gameObject);*
-
}*
- }*
}