Advertisement
Guest User

Untitled

a guest
Apr 8th, 2020
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class MoveCameraSimple : MonoBehaviour
  6. {
  7.     // Start is called before the first frame update
  8.     void Start()
  9.     {
  10.        
  11.     }
  12.  
  13.     // Update is called once per frame
  14.     void Update()
  15.     {
  16.         if( Input.GetMouseButtonDown(0) )
  17.         {
  18.             gameObject.GetComponent<Rigidbody>().AddForce( new Vector3( 0, 1, 0 ) * 50 );
  19.         }
  20.         if( Input.GetKeyDown( KeyCode.W ) )
  21.         {
  22.             gameObject.GetComponent<Rigidbody>().AddForce( new Vector3( 0, 0, 1 ) * 50 );
  23.         }
  24.         if( Input.GetKeyDown( KeyCode.S ) )
  25.         {
  26.             gameObject.GetComponent<Rigidbody>().AddForce( new Vector3( 0, 0, -1 ) * 50 );
  27.         }
  28.         if( Input.GetKeyDown( KeyCode.A ) )
  29.         {
  30.             gameObject.GetComponent<Rigidbody>().AddForce( new Vector3( -1, 0, 0 ) * 50 );
  31.         }
  32.         if( Input.GetKeyDown( KeyCode.D ) )
  33.         {
  34.             gameObject.GetComponent<Rigidbody>().AddForce( new Vector3( 1, 0, 0 ) * 50 );
  35.         }
  36.     }
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement