I want to make a game object to be inactive when the player is colliding with a game object (this I have done). now I want to wait for a few seconds and then activate it again. how can I do this?
here is my code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerMovement: MonoBehaviour
{
private float chubbyScore = 0;
private float coin = 0;
public float speed = 1;
public float jump = 1;
void Update()
{
Vector3 playerMovement = Vector3.zero;
playerMovement.x = Input.GetAxis("Horizontal");
transform.position += playerMovement * speed * Time.deltaTime;
transform.Translate(Vector3.forward * Time.deltaTime * speed);
if (Input.GetKeyDown(KeyCode.Space))
{
GetComponent<Rigidbody>().velocity = Vector3.up * jump;
}
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Pick Up"))
{
other.gameObject.SetActive(false);
coin += 1;
chubbyScore += 50;
}
}
}