Increasing friction or Adding force relative to transform position in Unity 2D?

Back again with a quick question! I have a few basic platforming mechanics going on in this scene. I have a prefab platform with an animation that loops back and forth between two different x positions, but does not begin looping until OnCollisionStay2D activates with my player object with the tag "Red cube".

But once the animation starts the red cube has very little friction with the platform and falls off. I have attempted to fix this AddRelativeForce in this script. Is there any way to increase the friction to where my player cube isn't slipping off? Or is there anyway to script my platform to add constant force to my player where I will move with platform seamlessly? Thank you so much for your time! You guys are a great help :)

using UnityEngine;
using System.Collections;

public class PlatformMovement : MonoBehaviour {

public Rigidbody2D rb;
public float speed;

void Start()
{
rb = GameObject.FindGameObjectWithTag ("Red Cube").GetComponent<Rigidbody2D> ();
}

void OnCollisionEnter2D(Collision2D coll)
{
if (coll.gameObject.tag == "Red Cube")
{
Debug.Log ("Something has entered this zone.");
GetComponent<Animation> ().Play ("Side To Side");
}
}

void OnCollisionStay2D(Collision2D coll)
{
if (coll.gameObject.tag == "Red Cube")
{
}

}

}


Try creating a physics material and adding it to your object and then in your code write the code below whenever you want to change the friction:

• I guess something might have changed in the new version so try this instead.  GetComponent<Collider2D> ().sharedMaterial.friction = VALUE FROM 0 TO 1 (FLOAT);  – Vadim Tatarnikov Jul 31 '15 at 12:41