Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEditor;
  4. using UnityEngine;
  5.  
  6. public class Drive : MonoBehaviour
  7. {
  8.     public float speed;
  9.     public Transform bulletLaunchPos;
  10.     public GameObject bulletPrefab;
  11.    
  12.    
  13.     // Update is called once per frame
  14.     void Update()
  15.     {
  16.         float translation = Input.GetAxis("Horizontal") * speed;
  17.         translation *= Time.deltaTime;
  18.         transform.Translate(translation, 0, 0);
  19.  
  20.         if (Input.GetKeyDown(KeyCode.Space))
  21.         {
  22.            
  23.             //Instantiate(bulletPrefab, bulletLaunchPos.position, Quaternion.identity);
  24.             GameObject b = PoolManager.singleton.Get("bullet");
  25.             if (b != null)
  26.             {
  27.                 b.transform.position = this.transform.position;
  28.                 b.SetActive(true);
  29.             }
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement