This commit is contained in:
corn
2026-06-07 22:59:32 +08:00
commit a62ff7379b
7171 changed files with 10015624 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
using UnityEngine;
namespace TrailsFX.Demos {
public class MoveObject : MonoBehaviour
{
void Update ()
{
Rigidbody rb = GetComponent<Rigidbody> ();
if (rb == null)
return;
Vector3 direction = Vector3.zero;
if (Input.GetKey (KeyCode.A)) {
direction = Vector3.right;
}
if (Input.GetKey (KeyCode.D)) {
direction = Vector3.left;
}
if (Input.GetKey (KeyCode.W)) {
direction = Vector3.back;
}
if (Input.GetKey (KeyCode.S)) {
direction = Vector3.forward;
}
rb.AddForce (direction * 10);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: fe71e39bb85f642f69fd5ced418b2b3c
timeCreated: 1554833269
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,31 @@
using UnityEngine;
namespace TrailsFX.Demos {
public class RotateObject : MonoBehaviour
{
public float speed = 100f;
Vector3 eulerAngles;
void Start ()
{
SetAngles ();
}
void Update ()
{
transform.Rotate (eulerAngles * (Time.deltaTime * speed));
if (Random.value > 0.995f) {
SetAngles ();
}
}
void SetAngles ()
{
eulerAngles = new Vector3 (Random.value - 0.5f, Random.value - 0.5f, Random.value - 0.5f);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 90b253c9d7c3241948ef68d83e2f3556
timeCreated: 1554833269
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,68 @@
using UnityEngine;
namespace TrailsFX.Demos {
public class Shooter : MonoBehaviour {
public float timeInterval = 0.3f;
public GameObject[] bulletPrefabs;
Quaternion targetRot;
float lastTargetTime;
Vector3 lookAt, previousLookAt;
GameObject[] bulletPool;
int poolIndex;
Vector3 startPos;
void Start() {
startPos = transform.position;
bulletPool = new GameObject[20];
previousLookAt = Vector3.up;
NewTarget();
}
void Update() {
float deltaTime = Time.deltaTime;
if (Vector3.Distance(startPos, transform.position) < 0.002f) {
if (Time.time - lastTargetTime > timeInterval) {
NewTarget();
Shoot();
}
transform.rotation = Quaternion.Lerp(transform.rotation, targetRot, deltaTime * 5f);
} else {
lastTargetTime = Time.time;
}
transform.position = Vector3.Lerp(transform.position, startPos, deltaTime * 4f);
}
void NewTarget() {
lookAt = new Vector3(Random.Range(-1f, 1f), Random.Range(0.5f, 1f), Random.Range(-1f, 1f));
targetRot.SetFromToRotation(previousLookAt, lookAt);
previousLookAt = lookAt;
lastTargetTime = Time.time;
}
void Shoot() {
if (++poolIndex >= bulletPool.Length) {
poolIndex = 0;
}
GameObject bullet = bulletPool[poolIndex];
if (bulletPool[poolIndex] == null) {
GameObject bulletPrefab = bulletPrefabs[Random.Range(0, bulletPrefabs.Length)];
bullet = Instantiate<GameObject>(bulletPrefab);
bulletPool[poolIndex] = bullet;
}
Vector3 cannonTip = transform.TransformPoint(new Vector3(0, 1.1f, 0));
Vector3 direction = (cannonTip - transform.position).normalized;
transform.position -= direction * 0.05f;
bullet.transform.position = cannonTip;
bullet.GetComponent<Rigidbody>().velocity = direction * (2f + Random.value);
bullet.GetComponent<Renderer>().enabled = true;
TrailEffect trail = bullet.GetComponent<TrailEffect>();
trail.Clear();
trail.duration = 0.5f + (Random.value * 2f);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d8a526c914fc546aba034c7705e5ca88
timeCreated: 1558457717
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: