using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayersController2D : MonoBehaviour
{
Animator animator;
Rigidbody2D rb2d;
SpriteRenderer spriteRenderer;
// Start is called before the first frame update
void Start()
{
animator = GetComponent();
rb2d = GetComponent();
spriteRenderer = GetComponent();
}
// Update is called once per frame
void Update()
{
if (Input.GetKey("d")) || Input.GetKey("right");
{
rb2d.velocity = new Vector2(2, 0);
}
{
else if (Input.GetKeyDown("a")) || Input.GetKeyDown("left");
rb2d.velocity = new Vector2(-2, 0);
}
}
}
↧