Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity2d movement

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

public class movement2D : MonoBehaviour
{
    Rigidbody2D body;

    float horizontal;
    float vertical;

    public float runSpeed = 10.0f;
    
    
    // Start is called before the first frame update
    void Start()
    {
        body = GetComponent<Rigidbody2D>();        
    }

    // Update is called once per frame
    void Update()
    {
        horizontal = Input.GetAxisRaw("Horizontal");
        vertical = Input.GetAxisRaw("Vertical");
    }

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

PREVIOUS NEXT
Code Example
Csharp :: how to find player gameobject in unity 
Csharp :: unity respawn c# 
Csharp :: how to remove all comma from string c# 
Csharp :: Search for a value into a list in c# 
Csharp :: take space separated input in c# 
Csharp :: carousel asp.net mvc beginner 
Csharp :: pause unity game 
Csharp :: c# get assembly directory 
Csharp :: on collision unity 
Csharp :: C# api get value from header 
Csharp :: rotate along normal unity 
Csharp :: c# dictionary get key by value 
Csharp :: how to display array in string in c# 
Csharp :: string to array c# 
Csharp :: vb.net check if datatable has rows 
Csharp :: class in c# 
Csharp :: frustum 
Csharp :: get file name from stream c# 
Csharp :: convert list string to list enum c# 
Csharp :: adding to a dictionary unity 
Csharp :: how to populate list in c# 
Csharp :: sieve 
Csharp :: context.Response.Body read stream .net 
Csharp :: read json from assets c# 
Csharp :: c# chance of 
Csharp :: translate int to string with x 0 before c# 
Csharp :: how to create a blazor client-side application in a command-line interface 
Csharp :: how to know pm or am C# 
Csharp :: dictionary all key where value c# 
Csharp :: wpf keydown detect if control key is down 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =