Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class Weapon : MonoBehaviour {
- public Rigidbody bullet;
- public Transform aimPoint;
- public float fireForce;
- public float rejection;
- private void Update() {
- if (Input.GetKeyDown(KeyCode.Space)) {
- Rigidbody copy = Instantiate(bullet, aimPoint.position, Quaternion.identity);
- Vector3 direction = aimPoint.forward;
- direction.x += Random.Range(-rejection, rejection);
- direction.y += Random.Range(-rejection, rejection);
- copy.AddForce(direction * fireForce);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement