Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- namespace MAGD272Demo
- {
- public class shootProjectile : MonoBehaviour
- {
- public GameObject projectile;
- public Transform shootPoint;
- [SerializeField] private KeyCode shootButton;
- // Update is called once per frame
- void Update()
- {
- if (Input.GetKeyDown(shootButton))
- {
- if (projectile == null)
- {
- Debug.Log("No projectile Set");
- }
- else
- {
- // the direction of the instantiation is linked to the object's transfom.rotation
- Instantiate(projectile, shootPoint.position, transform.rotation);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement