Answers for "how to make a 2d character move in unity 2020"

C#
2

how to make a 2d character move in unity 2020

float horizontal = Input.GetAxis("Horizontal");
 float vertical = Input.GetAxis("Vertical");
 float speed = 5.0f;
 
 void Update(){
     transform.position = new Vector3(horizontal, 0, vertical) * speed * Time.deltaTime;
 }
Posted by: Guest on March-06-2020
0

how to make a 2d character move in unity 2020

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovemeny : MonoBehaviour{

    public float speed;

    private Rigidbody2D rd;

    void Start(){
        rb = GetComponent<Rigidbody2D>();

    }
    void Update() {

        Vector2 moveInput = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"))
        moveVelocity = moveInput * speed;
    }

   void FixedUpdate(){

        rb.MovePosition(rb.position + moveVelocity * Time.fixedDeltaTime);

    }

}
Posted by: Guest on July-14-2021

Code answers related to "how to make a 2d character move in unity 2020"

C# Answers by Framework

Browse Popular Code Answers by Language