C# script to controll object movement in top down shooter like games.

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

// © 2017 TheFlyingKeyboard and released under MIT License
// theflyingkeyboard.net

public class TopDownCharacterMovement : MonoBehaviour {
    private Rigidbody2D myRigidbody;

    [SerializeField] private float moveSpeed;

    // Use this for initialization
    void Start () {
        myRigidbody = GetComponent<Rigidbody2D>();
  // Update is called once per frame
 void FixedUpdate () {
     Vector2 movingVector = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical"));

        myRigidbody.AddForce(movingVector * moveSpeed);
Script to make object rotate to mouse cursor
Unity C# 2D Top Down Shooter Movement
Tagged on:         

3 thoughts on “Unity C# 2D Top Down Shooter Movement

  • August 15, 2017 at 10:50 am

    Update this code plz

    • August 19, 2017 at 7:14 pm

      Updated 🙂

      • February 26, 2018 at 6:50 pm

        Can you please make a tutorial about this ?


Leave a Reply

Your email address will not be published. Required fields are marked *

This website stores some user agent data. These data are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to opt-out of any future tracking, a cookie will be set up in your browser to remember this choice for one year. I Agree, Deny