Advertisement
JonneOpettaja

Shooter.cs

Feb 3rd, 2019
726
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.51 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Shooter : MonoBehaviour {
  6.  
  7.     public GameObject shotPrefab;
  8.     public float shotVelocity = 20.0f;
  9.  
  10.     void Start () {
  11.        
  12.     }
  13.    
  14.     void Update () {
  15.         if (Input.GetMouseButtonDown (0))
  16.         {
  17.             GameObject shot = GameObject.Instantiate(shotPrefab, transform.position, transform.rotation) as GameObject;
  18.             shot.GetComponent<Rigidbody>().velocity = transform.forward * shotVelocity;
  19.         }
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement