-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBulletProjectile.cs
More file actions
35 lines (30 loc) · 880 Bytes
/
Copy pathBulletProjectile.cs
File metadata and controls
35 lines (30 loc) · 880 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BulletProjectile : MonoBehaviour
{
[SerializeField] private Transform vfxHitGreen;
[SerializeField] private Transform vfxHitRed;
private Rigidbody bulletRigidbody;
private void Awake()
{
bulletRigidbody = GetComponent<Rigidbody>();
}
private void Start()
{
float speed = 40f;
bulletRigidbody.velocity = transform.forward * speed;
}
private void OnTriggerEnter(Collider other)
{
if(other.GetComponent<BulletTarget>() != null)
{
Instantiate(vfxHitGreen, transform.position, Quaternion.identity);
}
else
{
Instantiate(vfxHitRed, transform.position, Quaternion.identity);
}
Destroy(gameObject);
}
}