- Home /
(NOOB QUESTION) ZIGZAG game platform drop
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Platform : MonoBehaviour {
void OnTriggerEnter(Collider col)
{
Debug.Log("Funçao de colisao iniciada");
if (col.gameObject.tag == "Player")
{
Debug.Log("FallDown Called");
Invoke("FallDown", 0.6f);
}
}
private void FallDown()
{
this.GetComponentInParent<Rigidbody>().isKinematic = false;
}
}
I wanna make the platform triggered drop after "0,6f" but only those whom i've passed on top. But now when I trigger the first platform the new that are been create are born with isKinematic = false, I don't want that. I need that only the platform thats been trigger drop.
Hi, it is strange... are you sure that your platform prefabs have Is$$anonymous$$inematic = false? If yes how do you instantiate your platforms?
Answer by bitsacpce · Jun 03, 2018 at 01:19 PM
Hey @EmPautaGames , I built a similar game last week.. This is the configuration for my platform. I have set iskinematic true and kept isgravity false.
and this is the code.
private void OnTriggerExit(Collider other)
{
if(other.gameObject.tag == "Ball")
{
Invoke("FallDown", 0.5f);
}
}
void FallDown()
{
GetComponentInParent<Rigidbody>().useGravity = true;
GetComponentInParent<Rigidbody>().isKinematic = false;
Destroy(transform.parent.gameObject, 2f);
}
let me know if this works for you. Cheers and happy coding.
Answer by EmPautaGames · Jun 19, 2018 at 01:35 PM
@bitsacpce I tried your way, but the same problem keeps happening. All new instances of the platform are being created with isKinematic = false and useGravity = true. Also notice that the ball starts to slow down after a while.