Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

C# top down 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 :: link form to a button in dashbord visual c# 
Csharp :: get script directory c# 
Csharp :: unity basic public options 
Csharp :: c# Case insensitive Contains(string) 
Csharp :: how to pause a console.writeline in C# 
Csharp :: extension method in c# 
Csharp :: number to character c# 
Csharp :: game maker transparent 
Csharp :: administrative priviledge in c# 
Csharp :: c# query string builder 
Csharp :: Block iFrames | How to Stop Your Website From Being iFramed 
Csharp :: rename join table ef core 
Csharp :: unity gui button width 
Csharp :: wpf binding ancestor codebehind 
Csharp :: how to edit .csproj file 
Csharp :: httpclient getstringasync 
Csharp :: tilemap shader 
Csharp :: get gameobject layermask 
Csharp :: Popup open close wpf 
Csharp :: autoit console write 
Csharp :: how to get params our of url c# VB 
Csharp :: c# convert xml to list string 
Csharp :: c# WriteLine() 
Csharp :: c# HttpResponseMessage postResponse = client.PostAsync 
Csharp :: how to configure visual studio for unity 
Csharp :: How can I get my stripe customer ID? 
Csharp :: c# convert datetime to timespan 
Csharp :: muovere un elemento in c# 
Csharp :: c# button click gets assigned the last value 
Csharp :: command parameter wpf 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =