Advertisement
VitalyD

Untitled

Mar 11th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.48 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class CamMove : MonoBehaviour
  6. {
  7.  
  8.     [SerializeField]
  9.     float speed = 5f;
  10.     [SerializeField]
  11.     float x, y;
  12.     Rigidbody2D rb;
  13.  
  14.  
  15.     void Start()
  16.     {
  17.         rb = GetComponent<Rigidbody2D>();
  18.     }
  19.  
  20.     void Update()
  21.     {
  22.         x = Input.GetAxis("Horizontal") * speed;
  23.         y = Input.GetAxis("Vertical") * speed;
  24.         rb.velocity = new Vector2(x, y);
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement