Horje
how to move your character in unity 2d game Code Example
how to move your character in unity 2d game
using UnityEngine;

public class PlayerMovement : MonoBehaviour  // PlayerMovement is the name of the script
{
    public float speed = 10;
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        float h = Input.GetAxis("Horizontal");
        float v = Input.GetAxis("Vertical");

        Vector2 pos = transform.position;

        pos.x += h * Time.deltaTime * speed;
        pos.y += v * Time.deltaTime * speed;

        transform.position = pos;
    }
}




Csharp

Related
remove a specific line in richtextbox c# Code Example remove a specific line in richtextbox c# Code Example
c# tryparse int Code Example c# tryparse int Code Example
detecting a right click unity Code Example detecting a right click unity Code Example
struct constructor c# Code Example struct constructor c# Code Example
c# find one object in list where Code Example c# find one object in list where Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
12