Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.50 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5.  
  6. public class PlayerController : MonoBehaviour{
  7.  
  8.     private Rigidbody2d rb2d;
  9.  
  10.     void Start()
  11.     {
  12.         rb2d = GetComponant<Rigidbody2d>();
  13.     }
  14.  
  15.  void FixedUpdate()
  16.     {
  17.         float moveHorizontal = Input.GetAxis("Horizontal");
  18.         float moveVertical = Input.GetAxis("Vertical");
  19.         Vector2 movement = new Vector2(moveHorizontal, moveVertical);
  20.         rb2d.AddForce(movement);    
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement