So I basically watched GucioDev’s video for the tutorial about falling platform. Here is the (Unity 5 2D Platformer Tutorial - Part 26 - Falling Platforms - YouTube)
but however, for some reason I’m not able to get it working. Here is the script that I used to test it out (same script just like in the video but without “GetComponent().isTrigger = True;” part)
The Script:
using UnityEngine;
using System.Collections;
public class FallingPlatform: MonoBehaviour {
private Rigidbody2D rb2d;
public float FallDelay;
void Start ()
{
rb2d = GetComponent<Rigidbody2D>();
}
void OnCollisonEnter2D (Collision2D col)
{
if (col.collider.CompareTag("Player"))
{
StartCoroutine(Fall());
}
}
IEnumerator Fall()
{
yield return new WaitForSeconds(FallDelay);
rb2d.isKinematic = false;
yield return 0;
}
}