- Home /
Question by
harvardchou · Apr 09 at 01:40 AM ·
gravitycollider2drendererdebug
my debug lines are running but the lines between are not
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");
}
}
Comment