19 lines
433 B
C#
19 lines
433 B
C#
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
public class Shooter : MonoBehaviour
|
||
|
|
{
|
||
|
|
public GameObject projectilePrefab;
|
||
|
|
public float shootPower = 10f;
|
||
|
|
|
||
|
|
public void Shoot(Vector2 dir)
|
||
|
|
{
|
||
|
|
GameObject proj = Instantiate(
|
||
|
|
projectilePrefab,
|
||
|
|
transform.position,
|
||
|
|
Quaternion.identity
|
||
|
|
);
|
||
|
|
|
||
|
|
Rigidbody2D rb = proj.GetComponent<Rigidbody2D>();
|
||
|
|
rb.linearVelocity = dir * shootPower;
|
||
|
|
}
|
||
|
|
}
|