J
J
JunEternal2022-02-22 03:42:31
C++ / C#
JunEternal, 2022-02-22 03:42:31

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);
        }
    }

Maybe this can be done somehow through Is kinematic?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
ConfusedUser, 2022-02-22
@ConfusedUser

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 question

Ask a Question

731 491 924 answers to any question