Advertisement
CakeMeister

UFO Player phan 1

Jul 17th, 2017
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.56 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Player : MonoBehaviour {
  6.  
  7.     public Rigidbody2D r2;
  8.     public Vector2 direction;
  9.     public float speed = 3f;
  10.     // Use this for initialization
  11.     void Start () {
  12.         r2 = GetComponent<Rigidbody2D>();
  13.     }
  14.    
  15.  
  16.     // Update is called once per frame
  17.     void Update () {
  18.         float h = Input.GetAxis("Horizontal");
  19.         float v = Input.GetAxis("Vertical");
  20.         direction.x = h;
  21.         direction.y = v;
  22.  
  23.         r2.AddForce(direction*speed);
  24.  
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement