Hiệu ứng là một phần không thể thiếu trong các game, hôm nay tôi sẽ hướng dẫn các bạn thêm một hiệu ứng trong Unity3D
Tiếp với bài 7 tôi sẽ thêm một yêu cầu là khi Cube1 va chạm Cube2 thì sẽ có thêm hiệu ứng phát ra khi va chạm
Bạn cần chuẩn bị một hình ảnh, ở đây tôi lấy 1 ngôi sao

Bây giờ bạn hãy thêm một Particle System vào, xem như hình dưới

Tiếp theo thêm các hiệu ứng

Tiếp đến bạn tạo thêm 1 Material sau đó add Star vào


Sau đó add thêm 1 Prefab rồi kéo Particle System vào Prefab, sau khi kéo Particle System vào rồi thì bạn hãy xóa nó đi hoặc Uncheck nó đi.

Tiếp đến là ta sẽ sử dụng Material vào trong Prefab Particle System, xem như hình dưới

Công đoạn tiếp theo là code, ta code một đoạn nho nhỏ

Bây giờ quay lại Unity chọn Cube1, phần Scripts bạn kéo Prefab vào mục Stars là xong

Bây giờ nhấn Play để thưởng thức nào, hãy thử check và uncheck phần Autodestruct xem có biểu hiện như nào nhé
