this is my normal player movement script:
using UnityEngine;
public class PlayerMovement : MonoBehaviour
{
public Rigidbody prb;
public float forwardForce = 1730f;
public float sidewaysForce = 570f;
private void FixedUpdate()
{
prb.AddForce(0, 0, forwardForce * Time.deltaTime);
var InputForce = Input.GetAxis("Horizontal");
prb.AddForce( InputForce * sidewaysForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
if (prb.position.y < -1f)
{
GameManager.playerDead = true;
}
/*
if (Input.GetKey("d"))
{
prb.AddForce(sidewaysForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
}
if (Input.GetKey("a"))
{
prb.AddForce(-sidewaysForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
}
*/
}
}
how do i make it so it works with a button?