Hello,
I a beginner to Unity and coding so sorry if I missed something obvious.
I am trying to remove friction from a platform to make a character “glide”.
I’ve tried using Physics Materials but it makes no difference, even lowering the Friction to 0. So I am trying to find a way to make the floor “icy” through code.
I am struggling to figure out how because all I can find is suggestions saying use the Physics Material.
Here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class characterscript : MonoBehaviour
{
public Rigidbody2D myRigidBody;
public float jumpstrength;
public float speed;
void Update()
{
if (Input.GetKeyDown(KeyCode.Space) == true)
{
myRigidBody.velocity = Vector2.up * jumpstrength;
}
if (Input.GetKey(KeyCode.LeftArrow))
{
var move = new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0);
transform.position += move * speed * Time.deltaTime;
}
if (Input.GetKey(KeyCode.RightArrow))
{
var move = new Vector3(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"), 0);
transform.position += move * speed * Time.deltaTime;
}
}
}
If you want more information from me please ask.