Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

top down view 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 :: c# calculate checksum of file 
Csharp :: unity basic public options 
Csharp :: concatanate two lists in c# 
Csharp :: c# create a dummy class 
Csharp :: c# convert string to datetime dd-mm-yyyy hh-mm-ss 
Csharp :: C# show text in another form 
Csharp :: GetComponent<Button().onClick 
Csharp :: wpf binding object get value 
Csharp :: c# progress bar timer 
Csharp :: install nuget package for S3 
Csharp :: sto playing audiosource 
Csharp :: unity how to make gamemanager instance 
Csharp :: c# asp.net hover tooltip 
Csharp :: unity audiosource play 
Csharp :: c# streamreader to file 
Csharp :: C# how to know if number is even or odd 
Csharp :: How to create a new object instance from a Type 
Csharp :: c# datagridview cell align center 
Csharp :: c# switch expression pattern matching 
Csharp :: how to get gravity from Rigidbody2D in c# 
Csharp :: linq select to list 
Csharp :: convert list of string to dictionary 
Csharp :: linq select 
Csharp :: c# return multiple values 
Csharp :: strong email validation regex c# 
Csharp :: c# copy an object 
Csharp :: adding to a dictionary class c# 
Csharp :: Convert a string to Integer in C# without library function 
Csharp :: how to make a C# game launcher 
Csharp :: C# print all properties of an object including children objects 
ADD CONTENT
Topic
Content
Source link
Name
2+2 =