Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ProjectileThrower : MonoBehaviour
- {
- [SerializeField] private Transform _camera;
- [SerializeField] private Projectile _projectilePrefab;
- private void Update()
- {
- if (Input.GetMouseButtonDown(0))
- {
- Vector3 cameraPosition = _camera.position + _camera.forward;
- Projectile projectile = Instantiate(_projectilePrefab, cameraPosition, Quaternion.identity);
- projectile.Throw(_camera.forward);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement