OneShotOneKill/Assets/Script/InGame/Actor/Shooter.cs

19 lines
433 B
C#
Raw Normal View History

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;
}
}