SHARE
TWEET

ZLP here u go

a guest Jun 19th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class controller : MonoBehaviour
  6. {
  7.  
  8.     public float speed = 10;
  9.  
  10.     private Rigidbody2D rig;
  11.  
  12.     public float jumpforce = 999999;
  13.  
  14.     public BoxCollider col;
  15.  
  16.  
  17.  
  18.     // Start is called before the first frame update
  19.     void Start()
  20.     {
  21.         rig = GetComponent<Rigidbody2D>();
  22.         col = GetComponent<BoxCollider>();
  23.     }
  24.  
  25.     // Update is called once per frame
  26.     void Update()
  27.     {
  28.         float hAxis = Input.GetAxis("Horizontal");
  29.         float vAxis = Input.GetAxis("Vertical");
  30.  
  31.         if (Input.GetKeyDown(KeyCode.UpArrow))
  32.         {
  33.             rig.velocity = Vector2.up * jumpforce;
  34.             Debug.Log("Up Arrow key was pressed.");
  35.         }
  36.  
  37.         Vector3 movement = new Vector3(hAxis,0, vAxis) * speed * Time.deltaTime;
  38.         rig.MovePosition(transform.position + movement);
  39.  
  40.      
  41.     }
  42.    
  43. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top