Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement