- Home /
Problem with friction.
I have a platform that Translates when the Player lands on it. The problem is the X movement of the platform doesn't carry the Player with it, making the Player slide right off. I tried adding a Physics Material 2D with various frictions values and changed the Player collider's linear drag but that didn't work.
Edit: Here's more info on the scene.
The character is moved with a simple rigidbody2D.velocity setup.
The platform is moved with Translation with vectors inherited from 2 game objects.
All colliders are box colliders. I'm sure this can be fixed by placing the Player and Platform in the same game object and then moving that, but can I do this with physics?
How are you moving the player? How are you moving the platform? What is your collider setup? What is your rigidbody setup?
Can you attach a snapshot of your inspector of platform?
With that snapshot, pleas show the colliders on the platform and character as the character is slipping. I would think you should just increase the static friction. You could increase the character mass or decrease the platform mass too. Are both physics controlled, or is the platform kinematic? For something like this, you also probably want the character's feet to have their own box colliders. A capsule collider has no solid contact area, but I don't know if PhysX is that realistic.
@supernat we don't even know if he's using a rigidbody for movement or a character controller.
Thanks for the replies guys! I've updated the question.
Answer by zee_ola05 · Feb 04, 2014 at 11:51 AM
Create a collider trigger on the player, make player a child of platform upon landing...
void OnTriggerStay2D(Collider2D other)
{
if(other.gameObject.tag == "platform")
{
transform.parent = other.transform;
}
}
void OnTriggerExit2D(Collider2D other)
{
if(other.gameObject.tag == "platform")
{
transform.parent = null;
}
}