Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

2d topdown movement unity

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

public class 2dMovement : MonoBehaviour
{
  //This also works with joystick, PS this is topdown movement

 private Rigidbody2D rb;
 public float MoveSpeed = 15f;


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

 void Update ()
 {
    private float vertical;
    private float horizontal; 
 
    horizontal = Input.GetAxisRaw("Horizontal");
    vertical = Input.GetAxisRaw("Vertical"); 
 }

 private void FixedUpdate()
 {  
    rb.velocity = new Vector2(horizontal * MoveSpeed, vertical * MoveSpeed);
 }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: unity diference protected and virtual 
Csharp :: c# user and password verification 
Csharp :: unity disable the display of the camera frustrum 
Csharp :: scroll two divs simultaneously site:stackoverflow.com 
Csharp :: C# declare object with values 
Csharp :: world space constant size 
Csharp :: return a list of list from yaml via C# 
Csharp :: Query mongodb collection as dynamic 
Csharp :: DateTime2 error in EF Blazor Web Application 
Csharp :: Rotate Object/Camera by Mouse 
Csharp :: loops in coding 
Csharp :: c# code for simplex method 
Csharp :: Request ID: XPBBR4XG1UWuX6fWF08_-jzYkrommVJjO7Os50CTYuZmiw7kMsFUkw== 
Csharp :: asp.net mvc select from many to many relationship 
Csharp :: how to integrate a c# and angular 9 
Csharp :: Showing a hidden WPF window 
Csharp :: for loop cs 
Csharp :: asp.net mvc class="" inline select 
Csharp :: add-users:430 Uncaught TypeError: $(...).validate is not a function 
Csharp :: sterge element din coada c# 
Csharp :: C# Func Delegate 
Csharp :: ascii art american flag 
Csharp :: sqlsinifi.baglanti.open() 
Csharp :: binary addition c# 
Csharp :: split a datatable based on number of rows 
Csharp :: c# switch expression 8.0 
Csharp :: plays ervices unity sigin 
Csharp :: .net return context.Result without extra new objectResult 
Csharp :: oldest living language 
Csharp :: c# class reference 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =