Created
April 8, 2019 23:30
-
-
Save DB-009/9c0bb3aa6008efefd5eeffd1d38e992e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class gunShooting : MonoBehaviour | |
{ | |
public playerControls _playerControls;//reference to playerControls script on player | |
public GameObject _bulletPrefab;//prefab of object were going to spawn | |
public Transform _bulletSpawnPoint;//position of where to spawn bullets to map | |
public float bulletSpeed;//speed of bullets on shoot | |
public void Shoot() | |
{ | |
// Debug.Log("bullet shot,spawned and moved kill it later"); | |
GameObject bullet = GameObject.Instantiate(_bulletPrefab, _bulletSpawnPoint.position, Quaternion.identity);//instantiate script to spawn bullet | |
bullet.GetComponent<Rigidbody>().AddForce(this.transform.forward * bulletSpeed, ForceMode.Impulse);//add force function to move bullet | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment