Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

C# top down view player movement

//Simple top down view player movement ( ̄︶ ̄)↗ 
//src-Brackeys(yt)

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

public class Player : MonoBehaviour
	{
		public float speed = 10f;
		public Rigidbody2D rb;
		Vector2 movement;
        
		void Update() 
	{
    	//Input
    	movement.x = Input.GetAxisRaw("Horizontal");
    	movement.y = Input.GetAxisRaw("Vertical");
	}

void FixedUpdate() 
	{
    	//Movement
    	rb.MovePosition(rb.position + movement * speed * Time.fixedDeltaTime);
	}

}
Comment

PREVIOUS NEXT
Code Example
Csharp :: spin with rigidbody 2d unity 
Csharp :: C# top down view player movement 
Csharp :: unity rigidbody freeze all rotation 
Csharp :: Startup.cs class is missing in .NET 6 
Csharp :: c# Case insensitive Contains(string) 
Csharp :: Get Mouse World Position 
Csharp :: how to make a character jump c# 
Csharp :: how to check if a file is running in c# 
Csharp :: Show empty message in data table angular material, If no data found 
Csharp :: Convert integers to written numbers C# 
Csharp :: dictionary all key where value c# 
Csharp :: C# http post request with file 
Csharp :: button event trigger wpf 
Csharp :: get current location latitude and longitude in xamarin - NAYCode.com 
Csharp :: unity c# image invisible 
Csharp :: browser folder in wpf 
Csharp :: indexing an array 
Csharp :: what is failure 
Csharp :: c# reflection get property value array 
Csharp :: c# if break 
Csharp :: color rgb to float c# 
Csharp :: c# string across multiple lines 
Csharp :: create stripe subscription pay_immediately 
Csharp :: by value by reference c# 
Csharp :: convert xml to json 
Csharp :: How to create a class and objects in C# 
Csharp :: c# list initialize 
Csharp :: how to get the dynamic year for your web app in mvc 
Csharp :: mongodb custom IIdGenerator 
Csharp :: c# create default instance of type 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =