#show your parenting code is your player
1 messages · Page 1 of 1 (latest)
it's a rigidbody
private void OnCollisionEnter(Collision collision)
{
if (collision.gameObject.CompareTag("Player"))
{
collision.gameObject.transform.SetParent(transform);
}
}
private void OnCollisionExit(Collision collision)
{
if (collision.gameObject.CompareTag("Player"))
{
collision.gameObject.transform.SetParent(null);
}
}
Make an addition box collider, set it to trigger the same size as your platform
change the code to be OnTriggerEnter
Alright lemme try
The new box collider should be on the parent ?
look my screeenshots
just clone the platform, put only boxcollider to trigger. You can disable mesh renderer. I have mine to green for debugging
put the script on the trigger
something like this
parent would be the platform MovingPlatform parent
okay let me get clear myself , so I have a parent object MovingPLatformParent a normal gameObject in which there is this moving platform child object with box collider and the script
I didn't got your point here
huh did you look at my example ?
it's exactly what u need to do
except mine character is Character Controller instead of rigidbody
it should work the same
Yes I saw it so you have a moving Platform parent in which there is a collider as well as script for the parent correct ?
the parent does nothing but hold the object
and has an animator for moving up and down
you ofc wanna parent player to the parent that holds it all instead of the platform graphics
Ohkayy Now i got a clear idea
right !!
exactly, however ur moving the platform should be done to the parent
think the parent as the MainObject
that holds the whole system
if you need more lmk
Yeah sure mate ! , anyways thanks for the help
you got it working ?
Uh no actually it's late night here so I stopped working as I was tired I'll try it tomorrow ! , Good night :)