27 lines
655 B
C#
27 lines
655 B
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
public class PlayerCarMuvement : MonoBehaviour
|
|||
|
{
|
|||
|
public float carHorizontalSpeed = 2f;
|
|||
|
private Vector3 carPosition;
|
|||
|
|
|||
|
public float maxDurability = 100f;
|
|||
|
|
|||
|
public float durability;
|
|||
|
|
|||
|
void Start()
|
|||
|
{
|
|||
|
carPosition = this.gameObject.transform.position;
|
|||
|
durability = maxDurability;
|
|||
|
}
|
|||
|
|
|||
|
void Update()
|
|||
|
{
|
|||
|
carPosition.x += Input.GetAxis("Horizontal") * carHorizontalSpeed * Time.deltaTime;
|
|||
|
carPosition.x = Mathf.Clamp(carPosition.x, -2.35f, 2.35f);
|
|||
|
this.gameObject.transform.position = carPosition;
|
|||
|
}
|
|||
|
|
|||
|
}
|