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);
}
}
Code Example |
---|
Csharp :: |
Csharp :: reverse a string in c# |
:: |
:: console.writeline c# |
:: |
Csharp :: |
Csharp :: |
Csharp :: |
Csharp :: instantiate list c# |
Csharp :: |
Csharp :: |
Csharp :: |
:: c# read file line by line |
:: simple player controller unity |
Csharp :: c# find all indexes |
:: |
Csharp :: unity pick random number |
Csharp :: unity rotate direction by angle |
Csharp :: |
:: |
Csharp :: how to open website from c# program |
Csharp :: c# int array length |
Csharp :: |
Csharp :: |
Csharp :: Operator Overloading | C# |
:: |
Csharp :: max value data annotation c# |
:: create list in c# |
:: |
:: |