wall_smash/Assets/Scripts/Player_Movement.cs
2025-04-15 13:34:19 +05:30

24 lines
659 B
C#

using UnityEngine;
public class Player_Movement : MonoBehaviour
{
public float Speed = 5;
public float maxX =7.5f;
float movementHorizontal;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
movementHorizontal = Input.GetAxis("Horizontal");
if((movementHorizontal >0 && transform.position.x<maxX) || (movementHorizontal<0 && transform.position.x > -maxX))
{
transform.position += Vector3.right * movementHorizontal * Speed*Time.deltaTime;
}
}
}