Asset Dump

This commit is contained in:
2026-06-03 13:46:13 -07:00
parent e362aaeb43
commit 9091388bc2
20821 changed files with 26544125 additions and 58 deletions
@@ -0,0 +1,59 @@
//
//NOTES:
//This script is used for DEMONSTRATION porpuses of the Projectiles. I recommend everyone to create their own code for their own projects.
//This is just a basic example.
//
#pragma warning disable 0168 // variable declared but not used.
#pragma warning disable 0219 // variable assigned but not used.
#pragma warning disable 0414 // private field assigned but not used.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraShakeSimpleScript : MonoBehaviour {
private bool isRunning = false;
private Animation anim;
void Start () {
anim = GetComponent<Animation> ();
}
public void ShakeCamera() {
if (anim != null)
anim.Play (anim.clip.name);
else
ShakeCaller (0.25f, 0.1f);
}
//other shake option
public void ShakeCaller (float amount, float duration){
StartCoroutine (Shake(amount, duration));
}
IEnumerator Shake (float amount, float duration){
isRunning = true;
Vector3 originalPos = transform.localPosition;
int counter = 0;
while (duration > 0.01f) {
counter++;
var x = Random.Range (-1f, 1f) * (amount/counter);
var y = Random.Range (-1f, 1f) * (amount/counter);
transform.localPosition = Vector3.Lerp (transform.localPosition, new Vector3 (originalPos.x + x, originalPos.y + y, originalPos.z), 0.5f);
duration -= Time.deltaTime;
yield return new WaitForSeconds (0.1f);
}
transform.localPosition = originalPos;
isRunning = false;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: de7cf7a6258c3634283fde9ddda2db91
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,172 @@
//
//
//NOTES:
//
//This script is used for DEMONSTRATION porpuses of the Projectiles. I recommend everyone to create their own code for their own projects.
//THIS IS JUST A BASIC EXAMPLE PUT TOGETHER TO DEMONSTRATE VFX ASSETS.
//
//
#pragma warning disable 0168 // variable declared but not used.
#pragma warning disable 0219 // variable assigned but not used.
#pragma warning disable 0414 // private field assigned but not used.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ProjectileMoveScript : MonoBehaviour {
public bool rotate = false;
public float rotateAmount = 45;
public bool bounce = false;
public float bounceForce = 10;
public float speed;
[Tooltip("From 0% to 100%")]
public float accuracy;
public float fireRate;
public GameObject muzzlePrefab;
public GameObject hitPrefab;
public List<GameObject> trails;
private Vector3 startPos;
private float speedRandomness;
private Vector3 offset;
private bool collided;
private Rigidbody rb;
private RotateToMouseScript rotateToMouse;
private GameObject target;
void Start () {
startPos = transform.position;
rb = GetComponent <Rigidbody> ();
//used to create a radius for the accuracy and have a very unique randomness
if (accuracy != 100) {
accuracy = 1 - (accuracy / 100);
for (int i = 0; i < 2; i++) {
var val = 1 * Random.Range (-accuracy, accuracy);
var index = Random.Range (0, 2);
if (i == 0) {
if (index == 0)
offset = new Vector3 (0, -val, 0);
else
offset = new Vector3 (0, val, 0);
} else {
if (index == 0)
offset = new Vector3 (0, offset.y, -val);
else
offset = new Vector3 (0, offset.y, val);
}
}
}
if (muzzlePrefab != null) {
var muzzleVFX = Instantiate (muzzlePrefab, transform.position, Quaternion.identity);
muzzleVFX.transform.forward = gameObject.transform.forward + offset;
var ps = muzzleVFX.GetComponent<ParticleSystem>();
if (ps != null)
Destroy (muzzleVFX, ps.main.duration);
else {
var psChild = muzzleVFX.transform.GetChild(0).GetComponent<ParticleSystem>();
Destroy (muzzleVFX, psChild.main.duration);
}
}
}
void FixedUpdate () {
if (target != null)
rotateToMouse.RotateToMouse (gameObject, target.transform.position);
if (rotate)
transform.Rotate(0, 0, rotateAmount, Space.Self);
if (speed != 0 && rb != null)
rb.position += (transform.forward + offset) * (speed * Time.deltaTime);
}
void OnCollisionEnter (Collision co) {
if (!bounce)
{
if (co.gameObject.tag != "Bullet" && !collided)
{
collided = true;
if (trails.Count > 0)
{
for (int i = 0; i < trails.Count; i++)
{
trails[i].transform.parent = null;
var ps = trails[i].GetComponent<ParticleSystem>();
if (ps != null)
{
ps.Stop();
Destroy(ps.gameObject, ps.main.duration + ps.main.startLifetime.constantMax);
}
}
}
speed = 0;
GetComponent<Rigidbody>().isKinematic = true;
ContactPoint contact = co.contacts[0];
Quaternion rot = Quaternion.FromToRotation(Vector3.up, contact.normal);
Vector3 pos = contact.point;
if (hitPrefab != null)
{
var hitVFX = Instantiate(hitPrefab, pos, rot) as GameObject;
var ps = hitVFX.GetComponent<ParticleSystem>();
if (ps == null)
{
var psChild = hitVFX.transform.GetChild(0).GetComponent<ParticleSystem>();
Destroy(hitVFX, psChild.main.duration);
}
else
Destroy(hitVFX, ps.main.duration);
}
StartCoroutine(DestroyParticle(0f));
}
}
else
{
rb.useGravity = true;
rb.linearDamping = 0.5f;
ContactPoint contact = co.contacts[0];
rb.AddForce (Vector3.Reflect((contact.point - startPos).normalized, contact.normal) * bounceForce, ForceMode.Impulse);
Destroy ( this );
}
}
public IEnumerator DestroyParticle (float waitTime) {
if (transform.childCount > 0 && waitTime != 0) {
List<Transform> tList = new List<Transform> ();
foreach (Transform t in transform.GetChild(0).transform) {
tList.Add (t);
}
while (transform.GetChild(0).localScale.x > 0) {
yield return new WaitForSeconds (0.01f);
transform.GetChild(0).localScale -= new Vector3 (0.1f, 0.1f, 0.1f);
for (int i = 0; i < tList.Count; i++) {
tList[i].localScale -= new Vector3 (0.1f, 0.1f, 0.1f);
}
}
}
yield return new WaitForSeconds (waitTime);
Destroy (gameObject);
}
public void SetTarget (GameObject trg, RotateToMouseScript rotateTo)
{
target = trg;
rotateToMouse = rotateTo;
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 12ba759cd568c0e47a7018ab70867a0d
timeCreated: 1498482809
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,74 @@
//
//NOTES:
//This script is used for DEMONSTRATION porpuses of the Projectiles. I recommend everyone to create their own code for their own projects.
//This is just a basic example.
//
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RotateToMouseScript : MonoBehaviour {
public float maximumLenght;
private bool use2D;
private Ray rayMouse;
private Vector3 pos;
private Vector3 direction;
private Quaternion rotation;
private Camera cam;
private WaitForSeconds updateTime = new WaitForSeconds (0.01f);
public void StartUpdateRay (){
StartCoroutine (UpdateRay());
}
IEnumerator UpdateRay (){
if (cam != null) {
if (use2D) {
Vector2 direction = Camera.main.ScreenToWorldPoint (Input.mousePosition) - transform.position;
float angle = Mathf.Atan2 (direction.y, direction.x) * Mathf.Rad2Deg;
if (angle > 180) angle -= 360;
rotation.eulerAngles = new Vector3 (-angle, 90, 0); // use different values to lock on different axis
transform.rotation = rotation;
} else {
RaycastHit hit;
var mousePos = Input.mousePosition;
rayMouse = cam.ScreenPointToRay (mousePos);
if (Physics.Raycast (rayMouse.origin, rayMouse.direction, out hit, maximumLenght)) {
RotateToMouse (gameObject, hit.point);
} else {
var pos = rayMouse.GetPoint (maximumLenght);
RotateToMouse (gameObject, pos);
}
}
yield return updateTime;
StartCoroutine (UpdateRay ());
} else
Debug.Log ("Camera not set");
}
public void RotateToMouse (GameObject obj, Vector3 destination ) {
direction = destination - obj.transform.position;
rotation = Quaternion.LookRotation (direction);
obj.transform.localRotation = Quaternion.Lerp (obj.transform.rotation, rotation, 1);
}
public void Set2D (bool state){
use2D = state;
}
public void SetCamera (Camera camera){
cam = camera;
}
public Vector3 GetDirection () {
return direction;
}
public Quaternion GetRotation () {
return rotation;
}
}
@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: b471b1df235ed774e9063eb5be974d7b
timeCreated: 1529269730
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,211 @@
//
//NOTES:
//This script is used for DEMONSTRATION porpuses of the Projectiles. I recommend everyone to create their own code for their own projects.
//This is just a basic example.
//
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class SpawnProjectilesScript : MonoBehaviour {
public bool useTarget;
public bool use2D;
public bool cameraShake;
public Text effectName;
public RotateToMouseScript rotateToMouse;
public GameObject firePoint;
public GameObject cameras;
public GameObject target;
public List<GameObject> VFXs = new List<GameObject> ();
private int count = 0;
private float timeToFire = 0f;
private GameObject effectToSpawn;
private List<Camera> camerasList = new List<Camera> ();
private Camera singleCamera;
void Start () {
if (cameras.transform.childCount > 0) {
for (int i = 0; i < cameras.transform.childCount; i++) {
camerasList.Add (cameras.transform.GetChild (i).gameObject.GetComponent<Camera> ());
}
if(camerasList.Count == 0){
Debug.Log ("Please assign one or more Cameras in inspector");
}
} else {
singleCamera = cameras.GetComponent<Camera> ();
if (singleCamera != null)
camerasList.Add (singleCamera);
else
Debug.Log ("Please assign one or more Cameras in inspector");
}
if(VFXs.Count>0)
effectToSpawn = VFXs[0];
else
Debug.Log ("Please assign one or more VFXs in inspector");
if (effectName != null) effectName.text = effectToSpawn.name;
if (camerasList.Count > 0) {
rotateToMouse.SetCamera (camerasList [camerasList.Count - 1]);
if(use2D)
rotateToMouse.Set2D (true);
rotateToMouse.StartUpdateRay ();
}
else
Debug.Log ("Please assign one or more Cameras in inspector");
if (useTarget && target != null)
{
var collider = target.GetComponent<BoxCollider>();
if (!collider)
{
target.AddComponent<BoxCollider>();
}
}
}
void Update () {
if (Input.GetKey (KeyCode.Space) && Time.time >= timeToFire || Input.GetMouseButton (0) && Time.time >= timeToFire) {
timeToFire = Time.time + 1f / effectToSpawn.GetComponent<ProjectileMoveScript>().fireRate;
SpawnVFX ();
}
if (Input.GetKeyDown (KeyCode.D))
Next ();
if (Input.GetKeyDown (KeyCode.A))
Previous ();
if (Input.GetKeyDown (KeyCode.C))
SwitchCamera ();
if (Input.GetKeyDown (KeyCode.Alpha1))
CameraShake ();
if (Input.GetKeyDown (KeyCode.X))
ZoomIn ();
if (Input.GetKeyDown (KeyCode.Z))
ZoomOut ();
}
public void SpawnVFX () {
GameObject vfx;
var cameraShakeScript = cameras.GetComponent<CameraShakeSimpleScript> ();
if (cameraShake && cameraShakeScript != null)
cameraShakeScript.ShakeCamera ();
if (firePoint != null) {
vfx = Instantiate (effectToSpawn, firePoint.transform.position, Quaternion.identity);
if (!useTarget)
{
if (rotateToMouse != null)
{
vfx.transform.localRotation = rotateToMouse.GetRotation();
}
else Debug.Log("No RotateToMouseScript found on firePoint.");
}
else
{
if (target != null)
{
vfx.GetComponent<ProjectileMoveScript>().SetTarget(target, rotateToMouse);
rotateToMouse.RotateToMouse(vfx, target.transform.position);
}
else
{
Destroy(vfx);
Debug.Log("No target assigned.");
}
}
}
else
vfx = Instantiate (effectToSpawn);
}
public void Next () {
count++;
if (count > VFXs.Count)
count = 0;
for(int i = 0; i < VFXs.Count; i++){
if (count == i) effectToSpawn = VFXs [i];
if (effectName != null) effectName.text = effectToSpawn.name;
}
}
public void Previous () {
count--;
if (count < 0)
count = VFXs.Count;
for (int i = 0; i < VFXs.Count; i++) {
if (count == i) effectToSpawn = VFXs [i];
if (effectName != null) effectName.text = effectToSpawn.name;
}
}
public void CameraShake () {
cameraShake = !cameraShake;
}
public void ZoomIn () {
if (camerasList.Count > 0) {
if (!camerasList [0].orthographic) {
if (camerasList [0].fieldOfView < 101) {
for (int i = 0; i < camerasList.Count; i++) {
camerasList [i].fieldOfView += 5;
}
}
} else {
if (camerasList [0].orthographicSize < 10) {
for (int i = 0; i < camerasList.Count; i++) {
camerasList [i].orthographicSize += 0.5f;
}
}
}
}
}
public void ZoomOut () {
if (camerasList.Count > 0) {
if (!camerasList [0].orthographic) {
if (camerasList [0].fieldOfView > 20) {
for (int i = 0; i < camerasList.Count; i++) {
camerasList [i].fieldOfView -= 5;
}
}
} else {
if (camerasList [0].orthographicSize > 4) {
for (int i = 0; i < camerasList.Count; i++) {
camerasList [i].orthographicSize -= 0.5f;
}
}
}
}
}
public void SwitchCamera () {
if (camerasList.Count > 0) {
for (int i = 0; i < camerasList.Count; i++) {
if (camerasList [i].gameObject.activeSelf) {
camerasList [i].gameObject.SetActive (false);
if ((i + 1) == camerasList.Count) {
camerasList [0].gameObject.SetActive (true);
rotateToMouse.SetCamera (camerasList [0]);
break;
} else {
camerasList [i + 1].gameObject.SetActive (true);
rotateToMouse.SetCamera (camerasList [i + 1]);
break;
}
}
}
}
}
}
@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: d2eb83ec655d71b498b43c9ebccd8066
timeCreated: 1515515037
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: