SHARE
TWEET

Untitled

a guest Nov 16th, 2019 88 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 CubeControl : MonoBehaviour
  6. {
  7.     public float speed = 10f;
  8.     Rigidbody rb;
  9.  
  10.     // Start is called before the first frame update
  11.     void Start()
  12.     {
  13.         rb = GetComponent<Rigidbody>();
  14.     }
  15.  
  16.     // Update is called once per frame
  17.     void Update()
  18.     {
  19.         float horizontal = Input.GetAxis ("Horizontal");
  20.         float vertical = Input.GetAxis("Vertical");
  21.  
  22.         Vector3 movement = new Vector3(horizontal * speed * Time.deltaTime, 0, vertical * speed * Time.deltaTime);
  23.  
  24.         rb.MovePosition(transform.position + movement);
  25.  
  26.     }
  27. }
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