Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

flat view player movement script

//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 :: Startup.cs class is missing in .NET 6 
Csharp :: C# order a sorted list by key 
Csharp :: linq select max value from list 
Csharp :: change color unity over time 
Csharp :: how to print to printer in c# 
Csharp :: spiral matrix 
Csharp :: how to know pm or am C# 
Csharp :: unity how to find the largest value out of 2 numbers 
Csharp :: Convert integers to written numbers C# 
Csharp :: stop playing audiosource 
Csharp :: encrypt password easiest way in web app .net 
Csharp :: unity stop physics 
Csharp :: c# double without exponential notation 
Csharp :: serial begin 
Csharp :: uwp roaming data sample 
Csharp :: how to use open hardware monitor in c# 
Csharp :: textbox gotfocus wpf 
Csharp :: c# datagridview center cell text 
Csharp :: .net core get runtime version 
Csharp :: C# Async Function simple 
Csharp :: system.random reuses numbers 
Csharp :: ssis sql query in script task 
Csharp :: instantiate c# 
Csharp :: save binary data to file c# 
Csharp :: create dropdown in datatable c# dynamically 
Csharp :: create a file in the directory of the exe and write to it c# 
Csharp :: c# sort array by value 
Csharp :: float into int unoity 
Csharp :: create anchor tag dynamically c# 
Csharp :: convert string to float win forms 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =