Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

geckoo

Moderators
  • Content Count

    2,824
  • Joined

  • Last visited

  • Days Won

    161

geckoo last won the day on August 5

geckoo had the most liked content!

Community Reputation

821 Excellent

About geckoo

  • Rank
    Суета сует и погоня за ветром

Profile Information

  • Gender
    Male
  • Location:
    - между раем и адом

Recent Profile Visitors

5,197 profile views
  1. Amazing behavior - I like how fishes spread, their dispersion . Nice work ++
  2. Interesting gameplay - beautiful aesthetic. However, and respectfully, this second video has nothing in common with the previous... You could post a new showcase. I wish you the best ++
  3. geckoo

    Shotgun bullets ?

    Respectfully I think that you have to change your way of mind it... In a previous project I used a simple tagged bullet prefab which was intantiated x times, applying a randomized force and angle. Only set prefab bullet and dispersion. Take a look at this part - I hope that it can help you ++ void fireRMB() { // simple fire rate using coroutine - efficient StartCoroutine(WaitMeRMB(frRMB)); // creates 9 bullets with randomize spread values for (var n = 0; n <= 8; n++) { var randomNumberX = Random.Range(-dispersion, dispersion); var randomNumberY = Random.Range(-dispersion, dispersion); var bullet = (GameObject)Instantiate(bulletPrefab, bulletSpawn.position, bulletSpawn.rotation); bullet.transform.Rotate(randomNumberX, randomNumberY, 0); // applies randomize force bullet.GetComponent<Rigidbody>().AddForce(bullet.transform.forward * Random.Range(800, 1100)); // play a sound if (shotgun != null) gm.GetComponent<GameManager>().playSound(shotgun, this.transform, true, Random.Range(0.4f, 0.75f), Random.Range(0.4f, 0.75f), shotgun.length); // destroy each bullet after 2.5 seconds Destroy(bullet, 2.5f); } }
  4. geckoo

    Shaders Bundle

    Why do you want to share those shaders on Asset Store when they are available on Itch.io for free and some of them here in our forum? Maybe if I can find time, eventually I could clean up and add some features - maybe ++
  5. geckoo

    Shaders Bundle

    Hello. You can download for free a big amount of shaders which I did a few years ago under Unity 5. It's more a large tutorial so as to understand shaders, but I think that you can find here some good stuff. Usually I use them in my projects like Abaddon, STR!PES, OneRoom or Azymuth, etc. A big part of them work well under Unity 2019.1, but you could see some bugs with old shaders. I guess that you can easily fix them according the new semantic. Please leave a comment if you noticed something wrong, explaining how to fix bugs. Thanks ++ https://geckoo1337.itch.io/camera-filter-for-unity
  6. Maybe because this post had been written almost 4 years ago?
  7. geckoo

    Time To Sprite

    The same, but allowing to create a background. Create an empty gameobject and put this script on it ++ using System.Collections; using UnityEngine; // convert time to sprite [RequireComponent(typeof(SpriteRenderer))] public class TimeToSprite : MonoBehaviour { Texture2D mTex; private Sprite mySprite; // sprite size which can be using like a fontSize [Range(1, 10)] public int fontSize = 5; // font and background color public Color _color = Color.red; public Color _background = Color.black; // each number use 5x3 pixels + 1 as space between them int marging = 4; // size int width; int height = 7; // five pixel + two for contour float time; // for deltaTime string str; // time as string string[] sChars = new string[] { "x", "x", "x", "x" }; // saved chars // each column will be displayed according a bit code int[] num0 = new int[] { 31, 17, 31 }; int[] num1 = new int[] { 17, 31, 16 }; int[] num2 = new int[] { 29, 21, 23 }; int[] num3 = new int[] { 21, 21, 31 }; int[] num4 = new int[] { 07, 04, 31 }; int[] num5 = new int[] { 23, 21, 29 }; int[] num6 = new int[] { 31, 21, 29 }; int[] num7 = new int[] { 01, 01, 31 }; int[] num8 = new int[] { 31, 21, 31 }; int[] num9 = new int[] { 23, 21, 31 }; int[] _dot = new int[] { 00, 10, 00 }; void Awake() { this.transform.localScale = new Vector3(fontSize, fontSize, 0); width = ((4 * marging) + 1); // because we use only 4 chars - 00.0 if (mTex == null) mTex = new Texture2D(width, height, TextureFormat.ARGB32, true); mTex.wrapMode = TextureWrapMode.Clamp; mTex.filterMode = FilterMode.Point; // pixel it mTex.Apply(); this.GetComponent<SpriteRenderer>().flipX = false; this.GetComponent<SpriteRenderer>().flipY = true; // fill sprite with background color for (int i = 0; i < height; i++) for (int j = 0; j < width; j++) mTex.SetPixel(j, i, _background); } // clear only concerned part of the sprite according a new pattern void refresh(int shift) { int x = 1; // a value to center process (one pixel inside sprite) for (int i = x; i < height - x; i++) for (int j = x; j < marging; j++) mTex.SetPixel(j + shift, i, _background); } void UpdateTexture() { mTex.Apply(); // apply new texture as sprite after modification var mySprite = Sprite.Create(mTex, new Rect(0.0f, 0.0f, mTex.width, mTex.height), new Vector2(0.5f, 0.5f), 100.0f, (uint)0); this.transform.GetComponent<SpriteRenderer>().sprite = mySprite; } void timer() { // we use only one digit str = time.ToString("00.0").Replace(",", "."); for (int i = 0; i < str.Length; i++) { // check if the new number is the same (or not) than the previous if (str.Substring(i, 1) != sChars[i]) { // erase the previous pixel zone for this index refresh(i * marging); if (str.Substring(i, 1) == "0") pencil(i * marging, num0, _color); else if (str.Substring(i, 1) == "1") pencil(i * marging, num1, _color); else if (str.Substring(i, 1) == "2") pencil(i * marging, num2, _color); else if (str.Substring(i, 1) == "3") pencil(i * marging, num3, _color); else if (str.Substring(i, 1) == "4") pencil(i * marging, num4, _color); else if (str.Substring(i, 1) == "5") pencil(i * marging, num5, _color); else if (str.Substring(i, 1) == "6") pencil(i * marging, num6, _color); else if (str.Substring(i, 1) == "7") pencil(i * marging, num7, _color); else if (str.Substring(i, 1) == "8") pencil(i * marging, num8, _color); else if (str.Substring(i, 1) == "9") pencil(i * marging, num9, _color); else if (str.Substring(i, 1) == ".") pencil(i * marging, _dot, _color); } // save the char at its index so as to compare it with the next sequence sChars[i] = str.Substring(i, 1); } // update our texture UpdateTexture(); } // convert a number as a bool array private bool[] ConvertByteToBoolArray(byte b) { bool[] r = null; r = new bool[height]; // don't read all bit for (int i = 0; i < r.Length; i++) r[i] = (b & (1 << i)) == 0 ? false : true; return r; } void pencil(int shift, int[] seq, Color color) { // read each integer as pixels column for (int i = 0; i < seq.Length; i++) { var lol = (byte)seq[i]; var ss = ConvertByteToBoolArray(lol); // read bool array to know where a black pixel must be displayed for (int j = 0; j < height; j++) if (ss[j] == true) mTex.SetPixel((shift + i) + 1, j + 1, color); } } ////////////////////////////////////////////////////////// // as an example, we show deltaTime IEnumerator Start() { timer(); while (true) { yield return new WaitForSeconds(0.09f); timer(); } } private void Update() { time += Time.deltaTime; // set max if (time >= 99.9f) time = 99.9f; } }
  8. geckoo

    Time To Sprite

    Since Unity 2019.1 use a comma instead a dot displaying float number as string, we have to replace it : str = time.ToString("00.0").Replace(",", ".");
  9. geckoo

    STR!PES

    Harder faster and optimized using Unity 2019 - available on itch.io ++ https://geckoo1337.itch.io/strpes
  10. geckoo

    Long time

    Hi Reaperkan. I hope that all is fine for you We live another era on forum - just a few people share their scripts, an opinion or something else. You can find always some questions or request so as to "add multiplayer to FPSkit", but nothing more. In other words, we die - slowly but surely. It's a pity ++
  11. geckoo

    Unity 2019.1

    Hello friends. Just a few words so as to share with you a recent experience. Working on my project STR!PES, I updated my Unity version to 2019.1 expecting some minor changes - as usual, it's always a little bit disturbing to update Unity for a newer version because sometimes old projects are broken or don't work correctly anymore. A little bit anxious I launched STR!PES on my new Unity version (I used Unity 2018.2 before) - and I noticed more or less 70 errors. I erased all previous log files, keeping only Assets folder with scripts, sounds, shaders, etc. After a project reconfiguration, all works fine as expected, but... Previously my project was good - oscillating between 25/45 batches. Now it stays constant - exactly 17 batches during all process and main execution is really really more smooth. With naked eye I notice a real improvement. I tried searching some explaination, willing to understand what it means, but I don't understand all features which have been added in newer Unity version. Now I am checking my previous projects (abaddon, theorem and more) so as to evaluate them under Unity 2019. I am very surprised by the result - better than I expected. Have you noticed too some improvement with your own projects? Have a nice day (like me today) ++
  12. geckoo

    Pool System

    A simple script so as to test the previous : SimplePoolSystem.PreLoadInstances to fill pool, SimplePoolSystem.GetInstance to activate an object, SimplePoolSystem.StoreInstance to store it for a next use ++ using UnityEngine; using System.Collections; public class Example : MonoBehaviour { public int width = 10; public int height = 10; public GameObject obj; public int preloadedObjects = 10; IEnumerator Start() { SimplePoolSystem.PreLoadInstances(obj, preloadedObjects, null); for (int y = 0; y < height; ++y) { for (int x = 0; x < width; ++x) { var lol = SimplePoolSystem.GetInstance(obj, null); lol.transform.position = new Vector3(x, y, 0); yield return new WaitForSeconds(0.1f); StartCoroutine(dd(lol)); } } } IEnumerator dd(GameObject go) { yield return new WaitForSeconds(1f); SimplePoolSystem.StoreInstance(go); } }
  13. geckoo

    Pool System

    Creating objects, usually we instantiate them. Then we can destroy them after use. However it requires some resource and when many instantiated objects must be created, there is an acceptable limit before lag. To avoid wasted resource, it is recommended to use a pooling sustem which preloads those objects, setting them active and storing them for a new use. This way, we limit objects in scene, using always the same (but you have to reset them) ++ using System.Collections.Generic; using UnityEngine; public static class SimplePoolSystem { private static Dictionary<string, List<GameObject>> pool = new Dictionary<string, List<GameObject>>(); private const string nameEnding = "(Clone)"; public static void PreLoadInstances(GameObject prefab, int number, Transform parent = null) { GameObject prefabInstance; bool setParent = parent != null; for (int i = 0; i < number; i++) { prefabInstance = Instantiate(prefab); if (setParent) prefabInstance.transform.SetParent(parent); StoreInstance(prefabInstance); } } private static GameObject GetInstanceFromPool(GameObject prefab) { GameObject prefabInstance = null; List<GameObject> instancesList; if (pool.TryGetValue(GeneratePrefabInstancesName(prefab), out instancesList)) if (instancesList.Count != 0) { prefabInstance = instancesList[0]; instancesList.RemoveAt(0); } else { Debug.Log("Not enough objects have been preloaded - create a new one"); prefabInstance = Instantiate(prefab); } return prefabInstance; } public static GameObject GetInstance(GameObject prefab, Transform parent = null) { GameObject prefabInstance = GetInstanceFromPool(prefab); prefabInstance.SetActive(true); if (parent != null) prefabInstance.transform.SetParent(parent); return prefabInstance; } public static void StoreInstance(GameObject gameObjectInstance) { gameObjectInstance.gameObject.SetActive(false); List<GameObject> instancesList; if (pool.TryGetValue(gameObjectInstance.name, out instancesList)) instancesList.Add(gameObjectInstance); else { instancesList = new List<GameObject>(); instancesList.Add(gameObjectInstance); pool.Add(gameObjectInstance.name, instancesList); } } public static void Clear() { pool.Clear(); } private static GameObject Instantiate(GameObject prefab) { GameObject prefabInstance = Object.Instantiate(prefab); prefabInstance.name = GeneratePrefabInstancesName(prefab); return prefabInstance; } private static string GeneratePrefabInstancesName(GameObject prefab) { return prefab.name + nameEnding; } }
  14. geckoo

    Time To Sprite

    The same script but with another font - 7*5 pixels ++ using System.Collections; using UnityEngine; // convert time to sprite [RequireComponent(typeof(SpriteRenderer))] public class TimeToSprite : MonoBehaviour { Texture2D mTex; private Sprite mySprite; // sprite size which can be using like a fontSize [Range(1, 10)] public int fontSize = 5; // font color public Color _color = Color.black; // each number use 7x5 pixels + 1 as space between them int marging = 6; // size int width; int height = 7; // seven pixel float time; // for deltaTime string str; // time as string string[] sChars = new string[] { "x", "x", "x", "x" }; // saved chars // each column will be displayed according a bit code int[] num0 = new int[] { 127, 65, 73, 65, 127 }; int[] num1 = new int[] { 65, 65, 127, 64, 64 }; int[] num2 = new int[] { 121, 73, 73, 73, 79 }; int[] num3 = new int[] { 73, 73, 73, 73, 127 }; int[] num4 = new int[] { 15, 8, 8, 8, 127 }; int[] num5 = new int[] { 79, 73, 73, 73, 121 }; int[] num6 = new int[] { 127, 73, 73, 73, 121 }; int[] num7 = new int[] { 1, 1, 1, 1, 127 }; int[] num8 = new int[] { 127, 73, 73, 73, 127 }; int[] num9 = new int[] { 79, 73, 73, 73, 127 }; int[] _dot = new int[] { 0, 0, 64, 0, 0 }; void Awake() { this.transform.localScale = new Vector3(fontSize, fontSize, 0); width = ((4 * marging) - 1); // because we use only 4 chars - 00.0 if (mTex == null) mTex = new Texture2D(width, height, TextureFormat.ARGB32, true); mTex.wrapMode = TextureWrapMode.Clamp; mTex.filterMode = FilterMode.Point; // pixel it mTex.Apply(); this.GetComponent<SpriteRenderer>().flipX = false; this.GetComponent<SpriteRenderer>().flipY = true; } // clear some part of the sprite according a new pattern void refresh(int shift) { for (int i = 0; i < height; i++) for (int j = 0; j < marging; j++) mTex.SetPixel(j + shift, i, Color.clear); } void UpdateTexture() { mTex.Apply(); // apply new texture as sprite after modification var mySprite = Sprite.Create(mTex, new Rect(0.0f, 0.0f, mTex.width, mTex.height), new Vector2(0.5f, 0.5f), 100.0f, (uint)0); this.transform.GetComponent<SpriteRenderer>().sprite = mySprite; } void timer() { // we use only one digit str = time.ToString("00.0"); for (int i = 0; i < str.Length; i++) { // check if the new number is the same (or not) than the previous if (str.Substring(i, 1) != sChars[i]) { // erase the previous pixel zone for this index refresh(i * marging); if (str.Substring(i, 1) == "0") pencil(i * marging, num0, _color); else if (str.Substring(i, 1) == "1") pencil(i * marging, num1, _color); else if (str.Substring(i, 1) == "2") pencil(i * marging, num2, _color); else if (str.Substring(i, 1) == "3") pencil(i * marging, num3, _color); else if (str.Substring(i, 1) == "4") pencil(i * marging, num4, _color); else if (str.Substring(i, 1) == "5") pencil(i * marging, num5, _color); else if (str.Substring(i, 1) == "6") pencil(i * marging, num6, _color); else if (str.Substring(i, 1) == "7") pencil(i * marging, num7, _color); else if (str.Substring(i, 1) == "8") pencil(i * marging, num8, _color); else if (str.Substring(i, 1) == "9") pencil(i * marging, num9, _color); else if (str.Substring(i, 1) == ".") pencil(i * marging, _dot, _color); } // save the char at its index so as to compare it with the next sequence sChars[i] = str.Substring(i, 1); } // update our texture UpdateTexture(); } // convert a number as a bool array private bool[] ConvertByteToBoolArray(byte b) { bool[] r = null; r = new bool[height]; for (int i = 0; i < r.Length; i++) r[i] = (b & (1 << i)) == 0 ? false : true; return r; } void pencil(int shift, int[] seq, Color color) { // read each integer as pixels column for (int i = 0; i < seq.Length; i++) { var lol = (byte)seq[i]; var ss = ConvertByteToBoolArray(lol); // read bool array to know where a black pixel must be displayed for (int j = 0; j < height; j++) if (ss[j] == true) mTex.SetPixel(shift + i, j, color); } } ////////////////////////////////////////////////////////// // as an example, we show deltaTime IEnumerator Start() { timer(); while (true) { yield return new WaitForSeconds(0.09f); timer(); } } private void Update() { time += Time.deltaTime; // set max if (time >= 99.9f) time = 99.9f; } }
  15. geckoo

    Time To Sprite

    Displaying a text on screen, usually we create a canvas as UI and it works very well on Unity. However I wanted to code a script which could apply a text or a value as a sprite - in other words, I tried to create an alternative UI, setting some features, creating my own font, etc. As an example, the basical code below allows to display time.deltaTime, checking values, applying modification, reading an array of booleans (according an integer) so as to paint some pixels on sprite (5*3). Also it could be used on a weapon so as to show how many bullets are available in the cartridge or maybe for health, and more. Simply put it on a game object. I hope that it will be useful someone ++ using System.Collections; using UnityEngine; // convert time to sprite [RequireComponent(typeof(SpriteRenderer))] public class TimeToSprite : MonoBehaviour { Texture2D mTex; private Sprite mySprite; // sprite size which can be using like a fontSize [Range(1, 10)] public int fontSize = 5; // font color public Color _color = Color.black; // each number use 5x3 pixels + 1 as space between them int marging = 4; // size int width; int height = 5; // five pixel float time; // for deltaTime string str; // time as string string[] sChars = new string[] { "x", "x", "x", "x" }; // saved chars // each column will be displayed according a bit code int[] num0 = new int[] { 31, 17, 31 }; int[] num1 = new int[] { 17, 31, 16 }; int[] num2 = new int[] { 29, 21, 23 }; int[] num3 = new int[] { 21, 21, 31 }; int[] num4 = new int[] { 07, 04, 31 }; int[] num5 = new int[] { 23, 21, 29 }; int[] num6 = new int[] { 31, 21, 29 }; int[] num7 = new int[] { 01, 01, 31 }; int[] num8 = new int[] { 31, 21, 31 }; int[] num9 = new int[] { 23, 21, 31 }; int[] _dot = new int[] { 00, 16, 00 }; void Awake() { this.transform.localScale = new Vector3(fontSize, fontSize, 0); width = ((4 * marging) - 1); // because we use only 4 chars - 00.0 if (mTex == null) mTex = new Texture2D(width, height, TextureFormat.ARGB32, true); mTex.wrapMode = TextureWrapMode.Clamp; mTex.filterMode = FilterMode.Point; // pixel it mTex.Apply(); this.GetComponent<SpriteRenderer>().flipX = false; this.GetComponent<SpriteRenderer>().flipY = true; } // clear some part of the sprite according a new pattern void refresh(int shift) { for (int i = 0; i < height; i++) for (int j = 0; j < marging; j++) mTex.SetPixel(j + shift, i, Color.clear); } void UpdateTexture() { mTex.Apply(); // apply new texture as sprite after modification var mySprite = Sprite.Create(mTex, new Rect(0.0f, 0.0f, mTex.width, mTex.height), new Vector2(0.5f, 0.5f), 100.0f, (uint)0); this.transform.GetComponent<SpriteRenderer>().sprite = mySprite; } void timer() { // we use only one digit str = time.ToString("00.0"); for (int i = 0; i < str.Length; i++) { // check if the new number is the same (or not) than the previous if (str.Substring(i, 1) != sChars[i]) { // erase the previous pixel zone for this index refresh(i * marging); if (str.Substring(i, 1) == "0") pencil(i * marging, num0, _color); else if (str.Substring(i, 1) == "1") pencil(i * marging, num1, _color); else if (str.Substring(i, 1) == "2") pencil(i * marging, num2, _color); else if (str.Substring(i, 1) == "3") pencil(i * marging, num3, _color); else if (str.Substring(i, 1) == "4") pencil(i * marging, num4, _color); else if (str.Substring(i, 1) == "5") pencil(i * marging, num5, _color); else if (str.Substring(i, 1) == "6") pencil(i * marging, num6, _color); else if (str.Substring(i, 1) == "7") pencil(i * marging, num7, _color); else if (str.Substring(i, 1) == "8") pencil(i * marging, num8, _color); else if (str.Substring(i, 1) == "9") pencil(i * marging, num9, _color); else if (str.Substring(i, 1) == ".") pencil(i * marging, _dot, _color); } // save the char at its index so as to compare it with the next sequence sChars[i] = str.Substring(i, 1); } // update our texture UpdateTexture(); } // convert a number as a bool array private bool[] ConvertByteToBoolArray(byte b) { bool[] r = null; r = new bool[height]; // don't read all bit for (int i = 0; i < r.Length; i++) r[i] = (b & (1 << i)) == 0 ? false : true; return r; } void pencil(int shift, int[] seq, Color color) { // read each integer as pixels column for (int i = 0; i < seq.Length; i++) { var lol = (byte)seq[i]; var ss = ConvertByteToBoolArray(lol); // read bool array to know where a black pixel must be displayed for (int j = 0; j < height; j++) if (ss[j] == true) mTex.SetPixel(shift + i, j, color); } } ////////////////////////////////////////////////////////// // as an example, we show deltaTime IEnumerator Start() { timer(); while (true) { yield return new WaitForSeconds(0.09f); timer(); } } private void Update() { time += Time.deltaTime; // set max if (time >= 99.9f) time = 99.9f; } }
×
×
  • Create New...