UnityProjekt/Assets/CharacterController.cs

22 lines
491 B
C#
Raw Normal View History

2020-11-05 22:10:41 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CharacterController : MonoBehaviour
{
private Rigidbody2D rb;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
if (Mathf.Abs(rb.velocity.x) > 10)
return;
rb.AddForce(new Vector2(Input.GetAxis("Horizontal") * 5, 0));
}
}