I’ve been trying to make an elevator that moves only downward to a platform and stops. But my script doesn’t seem to notice the player. Can you tell me what’s wrong please?
Here’s the script:
using UnityEngine;
using System.Collections;
public class FallingPlatform : MonoBehaviour {
bool isFalling = false;
float downSpeed = 1;
void OnTriggerEnter(Collider collider)
{
if (collider.gameObject.name == "player")
{
isFalling = true;
}
}
void Update()
{
if (isFalling)
{
downSpeed += Time.deltaTime/10;
transform.position = new Vector3 (transform.position.x,
transform.position.y-downSpeed,
transform.position.z);
}
}
}