Schmup-JIN/Assets/Scripts/BasicShooter.cs

30 lines
868 B
C#
Raw Normal View History

2019-09-17 15:43:40 +02:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BasicShooter : AbstractShooter
2019-09-17 15:43:40 +02:00
{
// Bullet that will be fired
[SerializeField] private GameObject _bullet;
private Transform _parentTransform;
// Direction the bullet will be going
[SerializeField] private Vector2 _direction = Vector2.right;
// Offset between parent and newly created bullet
[SerializeField] private Vector2 _offset = Vector2.zero;
2019-09-17 15:43:40 +02:00
void Start()
{
_parentTransform = GetComponentInParent<Transform>();
2019-09-17 15:43:40 +02:00
}
protected override void InstantiateProjectiles()
2019-09-17 15:43:40 +02:00
{
Vector3 newPosition = _parentTransform.position + (Vector3)_offset;
GameObject child = Instantiate(_bullet, newPosition, Quaternion.identity);
child.GetComponent<Bullet>().Direction = _direction;
2019-09-17 15:43:40 +02:00
}
}