How to prevent friction for character along vertical surfaces?

I have made a simple 2d character with movement using rigid-body physics, however when it tries to jump along side a wall, the friction causes it to stop half way up the wall, which is unrealistic and makes it difficult to jump in certain places. How can I prevent friction along vertical surfaces?

Here is my code:

public var spawnPoint : Transform;
public var deathPoint : Collider;
public var horizontalSpeed : float = 5.0;
public var verticalSpeed : float = 5.0;
public var acceleration : float = 5.0;
public var deceleration : float = 5.0;
public var jumpStrength : float = 5.0;
public var glideStrength : float = 2.0;
public var stampStrength : float = 5.0;
public var maxJumpSlope : float = 45.0;
@HideInInspector
public var horizontalVelocity : Vector2;
@HideInInspector
public var verticalVelocity : Vector2;
@HideInInspector
public var grounded : boolean = false;
@HideInInspector
public var xVelocity : float;

//move player to spawn point
transform.position = spawnPoint.position;

function FixedUpdate () {
	//jump only if player is touching ground
	if (Input.GetAxis("Vertical") > 0) {
		if (grounded) {
			rigidbody.AddForce(Vector2(0,jumpStrength));
		}
		else {
			rigidbody.AddForce(Vector2(0,glideStrength));
		}
	}
	else if (Input.GetAxis("Vertical") < 0) {
		rigidbody.AddForce(Vector2(0,-stampStrength));
	}
	
	//maintain player vertical velocity at consistent max speed
	verticalVelocity = Vector2(0,rigidbody.velocity.y);
	if (verticalVelocity.magnitude > verticalSpeed) {	
		verticalVelocity.Normalize();
		verticalVelocity *= verticalSpeed;
		rigidbody.velocity.y = verticalVelocity.y;
	}
			
		
	//accelerate player from user input
	rigidbody.AddForce(Vector2(Input.GetAxis("Horizontal") * acceleration,0));
	//maintain player horizontal velocity at consistent max speed
	horizontalVelocity = Vector2(rigidbody.velocity.x, 0);
	if (horizontalVelocity.magnitude > horizontalSpeed) {	
		horizontalVelocity.Normalize();
		horizontalVelocity *= horizontalSpeed;
		rigidbody.velocity.x = horizontalVelocity.x;
	}
	//decelerate player if on ground
	if (grounded && Input.GetAxis("Horizontal") == 0) {
		rigidbody.velocity.x = Mathf.SmoothDamp(rigidbody.velocity.x,0,xVelocity,deceleration);
	}
	
}

function OnCollisionStay (collisionInfo : Collision) {
	for (var contact : ContactPoint in collisionInfo.contacts) {
		//grounded is true if the slope the player is standing on is below a set angle
		if (Vector3.Angle(Vector3.up, contact.normal) < maxJumpSlope) {
			grounded = true;
		}
		//respawn player if fallen from edge
		if (contact.otherCollider == deathPoint) {
			transform.position = spawnPoint.position; 
		}
	}
}

function OnCollisionExit () {
	grounded = false;
}

Hi, @adgeofgalaxy

Static Colliders ::

A Static Collider is a GameObject that has a Collider but not a Rigidbody. Static Colliders are used for level geometry which always stays at the same place and never moves around. You can add a Mesh Collider to your already existing graphical meshes (even better use the Import Settings Generate Colliders check box), or you can use one of the other Collider types.

You should never move a Static Collider on a frame by frame basis. Moving Static Colliders will cause an internal recomputation in PhysX that is quite expensive and which will result in a big drop in performance. On top of that the behaviour of waking up other Rigidbodies based on a Static Collider is undefined, and moving Static Colliders will not apply friction to Rigidbodies that touch it. Instead, Colliders that move should always be Kinematic Rigidbodies.

UseFull links::1] Physics

2] Physics Material

@adgeofgalaxy Hope this info helps you out, Do accept it as Answer & Vote it Up if you find its HelpFull :slight_smile:

There is new unity component called platform Effector 2D that will allow you to do that:
more info here: