Breaking

Saturday, August 12, 2023

MOVE THE CIRCLE OR CUBE TO THE ARROW KEYS AND ASDW BUTTON IN UNITY 2D GAME PROJECT

 using System.Collections;

using System.Collections.Generic;
using UnityEngine;

public class player : MonoBehaviour
{
    public float movespeed;

    float XInput,YInput;
    // Start is called before the first frame update
    void Start()
    {
       
    }

    // Update is called once per frame
    void Update()
    {
       
    }
    private void FixedUpdate()
    {
        XInput = Input.GetAxis("Horizontal");
        YInput = Input.GetAxis("Vertical");
        transform.Translate(XInput * movespeed, YInput * movespeed,0);
    }
}

No comments:

Post a Comment