Soo, I am making a 2D game and currently was making platforms, managed to make them and I made a script, which when the character gets on top of the platform, he becomes child of it so he moves with it. Now when I wanted to create the exiting platform bit, I found out it just doesn’t trigger, for whatever reason. Here is the code, hope it’s some silly fast to solve mistake!
using UnityEngine;
using System.Collections;
public class MovingPlatformB : MonoBehaviour {
// Use this for initialization
void Start () {
}
void OnCollisionEnter2D (Collision2D other) {
if(other.gameObject.tag == "Player") {
other.transform.parent = transform;
Debug.Log ("fock");
}
}
void OnCollisionExit2D (Collision2D other) {
if (other.gameObject.tag == "Player") {
other.transform.parent = null;
Debug.Log ("???");
}
}
// Update is called once per frame
void FixedUpdate () {
transform.position = MovingPlatform.platformPosition;
}
}