using System.Threading;
using UnityEngine;
using Debug = UnityEngine.Debug;
using UnityEngine.SceneManagement;
public class PlayerMovement : MonoBehaviour
{
public Rigidbody RB;
public float forwardForce = 10f;
public float sideForce = 1000f;
// FixedUpdate when you use physics
void FixedUpdate()
{
RB.AddForce(forwardForce, 0, 0 * Time.deltaTime); // Add a foward force
if( Input.GetKey(KeyCode.LeftArrow) )
{
RB.AddForce(0, 0, sideForce * Time.deltaTime);
}
if( Input.GetKey(KeyCode.RightArrow) )
{
RB.AddForce(0, 0, -sideForce * Time.deltaTime);
}
I have made this code that moves my player left/right using left arrow and right arrow and now i want to add support for mobile i was thinking of adding two button but since im new to unity i dont know how to do that. Can someone please help me?