Hello, i’m having a big problem with a moving platform, well it’s not a platform it’s a train, wich has this script.
function OnTriggerEnter(col: Collider)
{
if(col.tag == "Player")
{
col.transform.parent = transform.parent;
}
}
function OnTriggerExit(col: Collider)
{
if(col.tag == "Player")
{
col.transform.parent = null;
}
}
this script just parents my player to my train when the player is inside the train, but since i have to use a rigidbody for my player so the game can detect collisions between a sword my character has and enemyes, when my characters gets out of the train he still continues to move with the train, so i don’t know what to do, i think it would be nice to have a solution for moving platforms, or in my case trains, that does not require parenting in order to work, but i have no idea on how to use other kinds of solutions.
So anybody knows why my character continues to move when he’s outside of the train?
or does anyone knows if there’s a better solution on moving platforms, trains or vehicles other than parenting?