Answer the question
In order to leave comments, you need to log in
How to make an object move down at a given speed?
Hey! Tell me how you can make an object (platform) after contact with the player move down at a given speed, then it will be deleted according to the existing code. I tried to do it through a rigidbody and the platform really moved down, but due to the impact of the ball on it, it started to fly.
public float force;
public float invoteDelay = 5f;
public GameObject gmo;
void DeleteObject()
{
Destroy(gmo);
}
public void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
{
Invoke("DeleteObject", invoteDelay);
}
}
Answer the question
In order to leave comments, you need to log in
Alternatively, start the coroutine in `OnTriggerEnter`, checking if it is already running, `yield return null;` each frame until it goes down and change transform.position += Time.deltaTime * vector3.down
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question