Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR 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);
	}

}
 
PREVIOUS NEXT
Tagged: #top #view #player #movement
ADD COMMENT
Topic
Name
7+9 =