Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

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 :: c# external ip 
Csharp :: top down view movement script 
Csharp :: Startup.cs class is missing in .NET 6 
Csharp :: concatanate two lists in c# 
Csharp :: unity collision.impulse 
Csharp :: unity unhide object 
Csharp :: Merge two List using Linq 
Csharp :: adding additional parameter to form submit 
Csharp :: v-slot 
Csharp :: unity cannot click button 
Csharp :: oracle c# parameters wont work 
Csharp :: c# short to int 
Csharp :: wpf keydown detect if control key is down 
Csharp :: declare multiple variables in for loop C# 
Csharp :: c# networkstream read all bytes 
Csharp :: system.drawing.color to system.consolecolor 
Csharp :: c# system cryptography hash string 
Csharp :: the name scripts does not exist in the current context mvc 5 
Csharp :: how to check if button is pressed unity 
Csharp :: run in wpf 
Csharp :: escape chars for regex c# 
Csharp :: c# subtract 24 hours form datetime 
Csharp :: C# Console font 
Csharp :: c# multiple exceptions same handler 
Csharp :: c# how to initialize an array 
Csharp :: truncate c# 
Csharp :: how to auto format c# code in visual studio 
Csharp :: unity move camera to player fluent 
Csharp :: c# driver.findelement to look for declared variable 
Csharp :: ef save changes 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =