Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity 2D Character movement

Discussion in 'Scripting' started by Jeremys556, Jan 22, 2019.

  1. Jeremys556

    Jeremys556

    Joined:
    Jan 15, 2017
    Posts:
    1
    Hello. I am in need of a 2d character movement script. I have been stuck for a while. It doesn't need to be too complicated just a simple one for now.
     
  2. beanie4now

    beanie4now

    Joined:
    Apr 22, 2018
    Posts:
    311
    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class FPS_Character_Controller : MonoBehaviour
    4. {
    5.     [Range(1,10)]
    6.     public float drag = 2;
    7.  
    8.     private void FixedUpdate()
    9.     {
    10.         //WASD
    11.         float h = Input.GetAxis("Horizontal")/drag;
    12.         float v = Input.GetAxis("Vertical")/drag;
    13.         transform.Translate(h,v,0);
    14.     }
    15. }
     
  3. qkson

    qkson

    Joined:
    Jan 15, 2018
    Posts:
    77
    Well, I recommend watching some tutorials on Unity or on programming generally. Don't expect to receive scripts just like that. It's really not that hard, seriously. Cheers!