- Home /
Question by
montymomentum_unity · Mar 30, 2020 at 05:07 PM ·
animationjumpingparent-child
Player height changes when exiting platform
I am working with moving platforms for my script and I've used a script that transforms the Player into a child of the Platform when entering a trigger that is on top of the platform, but whenever I exit the platform by jumping my jump gets cancelled by the script. I need to find a way to work around that.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlatformAttach : MonoBehaviour
{
public GameObject Player;
private void OnTriggerEnter(Collider other)
{
if (other.gameObject == Player)
{
Player.transform.parent = transform;
}
}
private void OnTriggerExit(Collider other)
{
if (other.gameObject == Player)
{
Player.transform.parent = null;
}
}
}
Comment