using System.Collections; using System.Collections.Generic; using UnityEngine; public class Weapon : MonoBehaviour { public Transform firePoint; public GameObject bulletPrefab; public Animator fireEffect; void Update() { if (Input.GetButtonDown("Fire1")) { Shoot(); } } //shooting logic void Shoot () { Instantiate(bulletPrefab, firePoint.position, firePoint.transform.rotation); fireEffect.SetTrigger("Fire"); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter