using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class fakeplat : MonoBehaviour
{
// Start is called before the first frame update
Collider2D mycollider;
public GameObject plat;
float startposx;
float startposy;
public float disappear;
public float drop;
IEnumerator waitfordisappear()
{
Debug.Log("Started Coroutine at timestamp : " + Time.time);
yield return new WaitForSecondsRealtime(1);
Debug.Log("Finished Coroutine at timestamp : " + Time.time);
plat.GetComponent<Renderer>().enabled = false;
plat.GetComponent<BoxCollider2D>().enabled= false;
}
void Start()
{
mycollider = GetComponent<Collider2D>();
startposx=transform.position.x;
startposy=transform.position.y;
}
// Update is called once per frame
void Update()
{
}
public void OnCollisionEnter2D(Collision2D collision)
{
if(collision.collider.tag=="destroy")
{
if(disappear==1)
{
StartCoroutine(waitfordisappear());
}
if(drop==1)
{
plat.GetComponent<Rigidbody2D>().gravityScale=1;
}
}
else
{
Debug.Log("not u");
}
}
public void reset()
{
transform.position= new Vector2(startposx,startposy);
Debug.Log("go back go back");
plat.GetComponent<Renderer>().enabled = true;
Debug.Log("see");
plat.GetComponent<BoxCollider2D>().enabled= true;
Debug.Log("touch");
plat.GetComponent<Rigidbody2D>().gravityScale=0;
Debug.Log("dont drop");
}
}
I am really confused, it works on some objects, but not on the others.
All the debug lines have been showing correctly, but the other codes don’t do their jobs.
The rederer and collider are still disabled after the reset fuction being called.
What’s going on?

