27 lines
651 B
C#
27 lines
651 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class Projectile : Weapon
|
|
{
|
|
[SerializeField] private float moveSpeed;
|
|
[SerializeField] private float lifetime = 5.0f;
|
|
private Rigidbody rig;
|
|
|
|
void Start()
|
|
{
|
|
rig = GetComponent<Rigidbody>();
|
|
Destroy(gameObject, lifetime);
|
|
rig.linearVelocity = transform.forward * moveSpeed;
|
|
}
|
|
void OnTriggerEnter(Collider other)
|
|
{
|
|
Character hit = other.GetComponent<Character>();
|
|
|
|
if (hit != owner && hit != null)
|
|
{
|
|
hit.TakeDamage(damage);
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
} |