Search Unity

Games W.A.S.D

Discussion in 'Projects In Progress' started by StarSilver22, Feb 6, 2024.

  1. StarSilver22

    StarSilver22

    Joined:
    Aug 7, 2022
    Posts:
    28
    Weird Action Survival Demo (no demo yet)
    this is a game I'm making with my brother who does the sound
    the setting of it is you're on an alien planet and it's you against the wild.
    The Main Focus is the environment for example if you go and kill all the peaceful animals. then what will the predators eat well you of course? or Thay might leave then you might lose a valuable item Thay drop.
    cut down all the tall grass animals hide in Thay will leave. too much pollution because of you. that won't be good for the surrounding environment.

    Road Map
    Add more foulage.
    Add textures and models.
    Add AI systems.
    Add more crafting smelting etc.
    Add durability and attack speed to items.
    Add more Biomes.
    Add hunger and stamina maybe others.
    Add animals.
    this will be receiving update prop weekly.

    I have a discord server where we can talk about game dev and other stuff like that.
    https://discord.gg/Kw8scxDu this will let you join the discord server.
    (does the discord code not work or does nobody want to click on it Pls Tell Me seriously Just Tell Me)

    Week 1
    right now, I don't have much to share it's the first week of development and I've been on the Grind with Sebastyn Lague Landmass Generation Series. I'm at E16 here what I've got so far. upload_2024-2-6_9-21-19.png

    now back to the grind
    I'll probably be giving updates weekly.
     
    Last edited: Apr 15, 2024 at 7:35 PM
    developer3244 likes this.
  2. StarSilver22

    StarSilver22

    Joined:
    Aug 7, 2022
    Posts:
    28
    Week 2
    I've been working on biome gen but the tutorial series I was using was never intended for biomes. I have managed to make some progress, but I don't really know what I'm doing lol so any help would be appreciated here's what I've got so far.

    Screenshot (46).png

    As you can see the biomes just repeat over and over again and I can't figure out how to get it too have an off set based on which chunk it's in here is the code for the biome gen

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class VoronoiDigram : MonoBehaviour
    6. {
    7.     [SerializeField] BiomeDate[] possibleBiomes;
    8.     [SerializeField] Color[] possibleColors;
    9.     [SerializeField] Material biomeMat;
    10.     [SerializeField] int mapSize;
    11.     [SerializeField] int gridSize;
    12.     int pixelsPerCell;
    13.      Vector2Int[,] pointPositions;
    14.      Color[,] colors;
    15.  
    16.     private void Start()
    17.     {
    18.         BiomeColors();
    19.         GenerateBiomes();
    20.         GenerateBiomes();
    21.     }
    22.  
    23.     private void Update()
    24.     {
    25.         if (Input.GetKeyDown(KeyCode.B))
    26.         {
    27.             GenerateBiomes();
    28.         }
    29.     }
    30.  
    31.     void BiomeColors()
    32.     {
    33.         for(int i = 0; i < possibleBiomes.Length; i++)
    34.         {
    35.             possibleColors[i] = possibleBiomes[i].color;
    36.         }
    37.     }
    38.  
    39.  
    40.     private void GenerateBiomes()
    41.     {
    42.         GeneratePoints();
    43.         Texture2D texture = new Texture2D(mapSize, mapSize);
    44.  
    45.         pixelsPerCell = mapSize / gridSize;
    46.  
    47.  
    48.  
    49.         for(int i = 0; i < mapSize; i++)
    50.         {
    51.             for(int j = 0; j < mapSize; j++)
    52.             {
    53.                 int gridX = i / pixelsPerCell;
    54.                 int gridY = j / pixelsPerCell;
    55.  
    56.                 float nearestDistance = Mathf.Infinity;
    57.                 Vector2Int nearestPoint = new Vector2Int();
    58.                 for (int a = -1; a < 2; a++)
    59.                 {
    60.                     for(int b = -1; b < 2; b++)
    61.                     {
    62.                
    63.  
    64.                         int x = gridX + a;
    65.                         int y = gridY + b;
    66.                         if (x < 0 || y < 0 || x >= gridSize || y >= gridSize) continue;
    67.  
    68.                
    69.  
    70.  
    71.                         float distance = Vector2Int.Distance(new Vector2Int(i, j), pointPositions[x, y]);
    72.                         if (distance < nearestDistance)
    73.                         {
    74.                             nearestDistance = distance;
    75.                             nearestPoint = new Vector2Int(x, y);
    76.                         }
    77.                     }
    78.                 }
    79.                 texture.SetPixel(i, j, colors[nearestPoint.x, nearestPoint.y]);
    80.  
    81.             }
    82.         }
    83.  
    84.         texture.Apply();
    85.         biomeMat.mainTexture = texture;
    86.     }
    87.  
    88.     private void GeneratePoints()
    89.     {
    90.         pointPositions = new Vector2Int[gridSize, gridSize];
    91.         colors = new Color[gridSize, gridSize];
    92.         for(int i = 0; i < gridSize; i++)
    93.         {
    94.             for(int j = 0; j < gridSize; j++)
    95.             {
    96.                 pointPositions[i, j] = new Vector2Int(i * pixelsPerCell + Random.Range(0, pixelsPerCell), j * pixelsPerCell + Random.Range(0, pixelsPerCell));
    97.                 colors[i, j] = possibleColors[Random.Range(0, possibleColors.Length)];
    98.             }
    99.         }
    100.     }
    101.  
    102.  
    103. }
    and here is the endless terrain script
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using Unity.VisualScripting;
    4. using UnityEditor.AssetImporters;
    5. using UnityEditor.Timeline;
    6. using UnityEngine;
    7. using UnityEngine.UIElements;
    8.  
    9. public class EndlessTerrainGen : MonoBehaviour
    10. {
    11.     Dictionary<Vector2, TerrainChunk> terrainChunkDictionary = new Dictionary<Vector2, TerrainChunk>();
    12.     static List<TerrainChunk> terrainChunksVisibleLstFrame = new List<TerrainChunk>();
    13.  
    14.     const float movementThresholdForChunkUpdate = 25f;
    15.     const float squrMovementThresholdForChunkUpdate = movementThresholdForChunkUpdate * movementThresholdForChunkUpdate;
    16.  
    17.     Vector2 viewerPosOld;
    18.  
    19.     public LODInfo[] detailLevels;
    20.     public static float maxViewDistance = 500f;
    21.     static TerrainGeneration terrainGen;
    22.  
    23.     public static Vector2 viewerPosition;
    24.  
    25.     [SerializeField] Material mapMaterial;
    26.  
    27.     [SerializeField] Transform viewer;
    28.  
    29.     [SerializeField] int chunkSize;
    30.     [SerializeField] int chunksVisibleInViewDist;
    31.  
    32.  
    33.  
    34.     private void Start()
    35.     {
    36.         terrainGen = FindObjectOfType<TerrainGeneration>();
    37.  
    38.         maxViewDistance = detailLevels[detailLevels.Length - 1].visibleDistThreshold;
    39.  
    40.         chunkSize = terrainGen.mapChunkSize - 1;
    41.         chunksVisibleInViewDist = Mathf.RoundToInt( maxViewDistance / chunkSize);
    42.  
    43.         UpdateVisibleChunks();
    44.     }
    45.     private void Update()
    46.     {
    47.         viewerPosition = new Vector2 (viewer.position.x, viewer.position.z) / terrainGen.terrainDate.uniformScale;
    48.         if((viewerPosOld - viewerPosition).sqrMagnitude > squrMovementThresholdForChunkUpdate)
    49.         {
    50.             viewerPosOld = viewerPosition;
    51.            UpdateVisibleChunks();
    52.         }
    53.  
    54.     }
    55.     void UpdateVisibleChunks()
    56.     {
    57.         int currentChunkCoordX = Mathf.RoundToInt(viewerPosition.x / chunkSize);
    58.         int currentChunkCoordZ = Mathf.RoundToInt(viewerPosition.y / chunkSize);
    59.         for(int i = 0; i < terrainChunksVisibleLstFrame.Count; i++)
    60.         {
    61.             terrainChunksVisibleLstFrame[i].SetVisible(false);
    62.         }
    63.         terrainChunksVisibleLstFrame.Clear();
    64.         for (int zOffSet = - chunksVisibleInViewDist; zOffSet <= chunksVisibleInViewDist; zOffSet++)
    65.         {
    66.             for (int xOffSet = -chunksVisibleInViewDist; xOffSet <= chunksVisibleInViewDist; xOffSet++)
    67.             {
    68.                 Vector2 viewedChunkCoord = new Vector2(currentChunkCoordX + xOffSet, currentChunkCoordZ + zOffSet);
    69.  
    70.                 if(terrainChunkDictionary.ContainsKey(viewedChunkCoord))
    71.                 {
    72.                     terrainChunkDictionary[viewedChunkCoord].UpdateTerrainChunk();
    73.            
    74.                 }
    75.                 else
    76.                 {
    77.                     terrainChunkDictionary.Add(viewedChunkCoord, new TerrainChunk(viewedChunkCoord, chunkSize, detailLevels, transform, mapMaterial));
    78.                 }
    79.             }
    80.         }
    81.     }
    82.     public class TerrainChunk
    83.     {
    84.         GameObject meshObject;
    85.         Vector2 position;
    86.         Bounds bounds;
    87.  
    88.         MeshRenderer meshRenderer;
    89.         MeshFilter meshFilter;
    90.         MeshCollider meshCollider;
    91.  
    92.         LODInfo[] detailLevel;
    93.         LODMesh[] lODMeshes;
    94.         LODMesh collisionLODMesh;
    95.  
    96.         MapDate mapDate;
    97.         bool mapDateReceived;
    98.         int previousLODIndex = -1;
    99.  
    100.         public TerrainChunk(Vector2 coord, int size, LODInfo[] detailLevel, Transform parent, Material material)
    101.         {
    102.             this.detailLevel = detailLevel;
    103.  
    104.             position = coord * size;
    105.             bounds = new Bounds(position, Vector2.one * size);
    106.             Vector3 positionV3 = new Vector3(position.x, 0, position.y);
    107.  
    108.             meshObject = new GameObject("Terrain Chunk");
    109.             meshRenderer = meshObject.AddComponent<MeshRenderer>();
    110.             meshFilter = meshObject.AddComponent<MeshFilter>();
    111.             meshCollider = meshObject.AddComponent<MeshCollider>();
    112.  
    113.             meshObject.transform.position = positionV3 * terrainGen.terrainDate.uniformScale;
    114.             meshObject.transform.localScale = Vector3.one * terrainGen.terrainDate.uniformScale;
    115.             meshObject.transform.parent = parent;
    116.             meshRenderer.material = material;
    117.  
    118.             lODMeshes = new LODMesh[detailLevel.Length];
    119.             for(int i = 0; i < detailLevel.Length; i++)
    120.             {
    121.                 lODMeshes[i] = new LODMesh(detailLevel[i].lOD, UpdateTerrainChunk);
    122.                 if (detailLevel[i].useforColider)
    123.                 {
    124.                     collisionLODMesh = lODMeshes[i];
    125.                 }
    126.             }
    127.  
    128.             SetVisible(false);
    129.  
    130.             terrainGen.RequestMapDate(position,OnMapDateReceived);
    131.         }
    132.  
    133.         void OnMapDateReceived(MapDate mapDate)
    134.         {
    135.             this.mapDate = mapDate;
    136.             mapDateReceived = true;
    137.  
    138.    
    139.    
    140.  
    141.             UpdateTerrainChunk();
    142.         }
    143.  
    144.  
    145.  
    146.         public void UpdateTerrainChunk()
    147.         {
    148.             if (mapDateReceived)
    149.             {
    150.               float viewerDistFromNestEdge = Mathf.Sqrt( bounds.SqrDistance(viewerPosition));
    151.               bool visible = viewerDistFromNestEdge <= maxViewDistance;
    152.               SetVisible(visible);
    153.               if (visible)
    154.               {
    155.                   int lODIndex = 0;
    156.                   for(int i = 0; i < detailLevel.Length - 1; i++)
    157.                   {
    158.                       if(viewerDistFromNestEdge > detailLevel[i].visibleDistThreshold)
    159.                       {
    160.                           lODIndex = i + 1;
    161.                       }
    162.                       else
    163.                       {
    164.                           break;
    165.                       }
    166.                   }
    167.                   if(lODIndex != previousLODIndex)
    168.                   {
    169.                       LODMesh lODMesh = lODMeshes[lODIndex];
    170.                       if (lODMesh.hasMesh)
    171.                       {
    172.                           previousLODIndex = lODIndex;
    173.                           meshFilter.mesh = lODMesh.mesh;
    174.                       }
    175.                       else if (!lODMesh.hasRequestedMesh)
    176.                       {
    177.                         lODMesh.RequestMesh(mapDate);
    178.                       }
    179.                   }
    180.  
    181.                   if(lODIndex == 0)
    182.                   {
    183.                         if (collisionLODMesh.hasMesh)
    184.                         {
    185.                             meshCollider.sharedMesh = collisionLODMesh.mesh;
    186.                         }
    187.                         else if (!collisionLODMesh.hasRequestedMesh)
    188.                         {
    189.                             collisionLODMesh.RequestMesh(mapDate);
    190.                         }
    191.                
    192.                   }
    193.  
    194.                     terrainChunksVisibleLstFrame.Add(this);
    195.               }
    196.             }
    197.    
    198.         }
    199.  
    200.         public void SetVisible(bool visible)
    201.         {
    202.             meshObject.SetActive (visible);
    203.         }
    204.  
    205.         public bool IsVisible()
    206.         {
    207.             return meshObject.activeSelf;
    208.         }
    209.     }
    210.  
    211.     class LODMesh
    212.     {
    213.         public Mesh mesh;
    214.         public bool hasRequestedMesh;
    215.         public bool hasMesh;
    216.         int lOD;
    217.  
    218.         System.Action updateCallBack;
    219.  
    220.         public LODMesh(int lOD, System.Action updateCallBack)
    221.         {
    222.             this.lOD = lOD;
    223.             this.updateCallBack = updateCallBack;
    224.         }
    225.  
    226.         void OnMeshDateReceived(MeshDate meshDate)
    227.         {
    228.             mesh = meshDate.CreateMesh();
    229.             hasMesh = true;
    230.  
    231.             updateCallBack();
    232.         }
    233.  
    234.         public void RequestMesh(MapDate mapDate)
    235.         {
    236.             hasRequestedMesh = true;
    237.             terrainGen.RequestMeshDate(mapDate, lOD, OnMeshDateReceived);
    238.         }
    239.     }
    240.  
    241.     [System.Serializable]
    242.     public struct LODInfo
    243.     {
    244.         public int lOD;
    245.         public float visibleDistThreshold;
    246.         public bool useforColider;
    247.     }
    248. }
    so, I decided to take a break from biome gen. and started on trees.

    Screenshot (47).png
    Thay drop branches and seeds over time and if you walk up to them, you can shack them to make them fall faster right now all the models are place holders. Next I'll be working on inventory tell me what you think.
     
    Last edited: Feb 28, 2024
    developer3244 and DevsGoingViral like this.
  3. StarSilver22

    StarSilver22

    Joined:
    Aug 7, 2022
    Posts:
    28
    Week 3
    this week I've been hard at work on the inventory and hot bar. I decided to take inspersion from "Ark" and "Subnatica" (partly because there easier to make) because Thay feel nice, and I really enjoyed the games.

    Here's a screenshot of them in my game.
    Screenshot (52).png

    so, on the left you have your items, and, on the right, you have your blue prints the bottom is obviously you hotbar. Basically, which ever hot bar slot is selected when you hit the equip button is where the item gets assigned. The hotbar is not 100% complete but it's not very far from it.
    Crafting
    I've got that working so basically when you hit craft it checks if you have the required items then it checks if you have the required tools. Then it has you pick out which items and tool you want to use.
    Then you start a mini game (which I kept short, so it doesn't become too tidies) and depending on how high quality your tools and ingredients are depends on how easy it is to get a better item.
    Screenshot (54).png

    I do plan to change up the UI in the future. The goal of the mini game is that when the in this case orange node gets inside of the green one you click on it there's two types of nodes the orange one you see on screen stops in the center of the screen then it's value slowly start's draining away it also stops all other nodes from spawning till you click it.
    the second node doesn't stop on the dot and goes across the screen pretty quickly.

    This week I plan to add spawning for the trees and more crafting also add durability to the items.
     
    developer3244 likes this.
  4. StarSilver22

    StarSilver22

    Joined:
    Aug 7, 2022
    Posts:
    28
    Week 4
    Woohoo it's been one month since the start of development! The post has gotten 200 something views but zero likes or comments.
    Any way this week the first thing I did was finish the hot bar. Then I had my siblings play test it (Thay broke it) so then I had to fix all the things Thay broke. the glitches where the usual walking though trees crafting when you don't have the required items flying. so, I spent a while fixing all that then I started on
    Biomes Kinda
    This is the first system I came up with. At spawn there's one empty game Object that checks if there's anything under it. Then it goes to the ground and spawns up to ten other spawners in random positions then it also spawns a random amount of tree and rock spawners. then the next set of spawners does the same thing and I think you can see what's wrong with this. It crashed the game.

    So, the next method I tried was similar the difference was that instead of the spawners spawning them self's every chunk made its own spawner that only spawn tree and rock spawners. this how ever did not look natural at all and had very noticeable gaps in where there just wasn't anything.

    The third method I tried was where the spawners instead of spawning a random amount off tree or rock spawners Thay spawn a biome from an array. Right now, there is only one biome forest, but I know it's very expandable I also added grass and reeds (I guess)

    Screenshot (56).png
    the grass is really laggy right now, but I plan to fix that this week.
    but any way then I found this video abut lighting.
    Unity URP Tutorial - Lighting And Post-Processing
    By LMHPOLY
    Screenshot (57).png

    you can't see that much a difference in this screen shot but trust me there's a difference.
    I would Definitely check it out the video If I where you.

    then I told my brother I changed the lighting, and he asked if I added A Day night cycle, and I said no and as a joke he said he was disappointed in me, so I added a day and night cycle.
    At first, I tried on my own, but I ended up using this video.
    Creating a Day/Night Cycle (Unity Tutorial)
    by


    Ketra Games
    this is the result with both the videos at night.
    Screenshot (58).png

    It's kind of scary perfect time for something to jump out from behind and eat the player.

    Welp on to week 5 I'll be trying to fix the lag in the game. some feedback on how I could do this would be vary Apricated.
     
    developer3244 likes this.
  5. StarSilver22

    StarSilver22

    Joined:
    Aug 7, 2022
    Posts:
    28
    Week 5
    So not much to say this week I haven't had much time, and the games frame rate is kinda discouraging but I think this week will be different and I'll make more progress.

    all I've managed to do without it is take the frame rate from below 15 to sometimes above 15.

    Music
    so Starfall here I'm the music sound maker so here is some of that
    https://www.bandlab.com/post/b0dcb08f-b6d9-ee11-85f9-6045bd2e11f9

    https://www.bandlab.com/post/60794609-9ed2-ee11-85f9-6045bd2e11f9
    (Links to the music on "BandLab")

    ok StarSilver again hope you like StarFalls music he's got more in progress and now week 6 will be more debugging so see you then (unless someone comment in that cass I'll be glad to replay).
     
    Last edited: Mar 4, 2024
    developer3244 likes this.
  6. StarSilver22

    StarSilver22

    Joined:
    Aug 7, 2022
    Posts:
    28
    Week 6
    same as last time I haven't had that much time and all I did was bug fixes.

    this week I'll hopefully get to the good stuff can't make any promises though. :(
     
    developer3244 likes this.
  7. developer3244

    developer3244

    Joined:
    Jan 4, 2024
    Posts:
    88
  8. StarSilver22

    StarSilver22

    Joined:
    Aug 7, 2022
    Posts:
    28
    I'm not at the play testing faze yet not much to "play" and as for a video my google account is acting up so I can't really do that ether unless there's a way I'm unaware of.

    thanks for the tip though I'll definitely be going back to that.
     
    Last edited: Mar 18, 2024
    developer3244 likes this.
  9. StarSilver22

    StarSilver22

    Joined:
    Aug 7, 2022
    Posts:
    28
    Week 7
    Ok so to I got the game to run just below 50 frames per second. then we added two more
    biomes (to test how the biome spawning worked) the meadow and the marsh.
    [ Screenshot (63).png
    This is the meadow later on all the biomes will have their own tree, and grass types. But for now, this will do.

    Screenshot (64).png
    Here is the marsh right now it isn't that different from a forest like I said we just wanted to test out how the biomes would spawn/blend.

    I also changed the grass Unity's primitives are insanely laggy. If you can avoid using primitives, do it!
    Screenshot (65).png

    Current known things causing lag
    -The grass it did get redone but with how much I need for the meadow it's still too many vertices.
    Possible fixes redo it again and spare no expense (probably not), use billboards for far away grass, use a really advanced script to render the grass (please don't be this one :()
    -The reeds are currently using Unity's primitive objects so it's using way too many vertices.
    Possible fixes make a new module in Blender.
    -The spawner script so this is how the game spawn's things each chunk spawns in and has a spawner that choices a forest, meadow, or marsh spawner which then spawns all the things it needs for the biome trees grass rocks etc.
    that part works fine the part that doesn't work is the trees each have this script and over time they drop sticks and seeds (which do nothing right now). They also can be interacted with by the player to make them drop things.
    and thousands of trees checking if a certain amount of time has paced might be a bit to laggy.
    Possible fixes ditch this mechanic hahahah. Just kidding I'll have to make the script work with unity's job system.

    Music
    More music!!!
    here's the link https://www.bandlab.com/post/e247d7c6-c8e3-ee11-85fb-000d3a425266

    glad to have a week that doesn't just say did bug fixes. :D
     
    Last edited: Mar 25, 2024
    developer3244 likes this.
  10. StarSilver22

    StarSilver22

    Joined:
    Aug 7, 2022
    Posts:
    28
    Week 8
    Ok so this week we got a few things done.
    first StarFall has started work redoing the reed.
    Screenshot (68).png
    This is not the final version and I know it doesn't look like a read but remember this game takes place on an alien plant.
    Also, the ring on the top glows slightly in the dark.
    Screenshot (70).png

    next I added a new crafting recipe the reed rope. You'll use this to make most of your primitive tools knifes hammers axes etc.
    Then we added the primitive hatchet.
    Screenshot (69).png
    Like most things in the game this is a place holder

    so far, everything is working mostly right.

    Next week Is going to be code clean up and like always fixing the lag.
     
    Last edited: Mar 25, 2024
  11. developer3244

    developer3244

    Joined:
    Jan 4, 2024
    Posts:
    88
    Now i started to think about a thing: even if not intentionally, are you remaking Minecraft? Cause this is getting pretty similar. Craftings, starting with wood, etc. is things that compose the game (except that minecraft is voxel and yours have plenty interresing and promising graphics)

    The game style is reminding me the game Slime rancher 2 (a sucessfull game made in unity :)), which have some interessing stuff that you could use as base. As your game is set on an alien planet, you could make good use of light, emissions, add space themed content, and put creativity to work.

    Also, is enough for that bad quality grass, wood, etc, right? I can do some small texture maps if you want or, if there is no problem in using a little bit of money, you could try the site textures.com, a good place for find any content (particulary texture maps with plenty resolution and models)
     
  12. StarSilver22

    StarSilver22

    Joined:
    Aug 7, 2022
    Posts:
    28
    The wood is not staying the same neither is the grass there still place holders.

    As for the thing about MineCraft there are tons of survival games ARK, Subnatice, Terraria, Valiham, Astroneer, and then the new one Pokemon with guns lol. In most of these you start with nothing but your hands so naturally you get what ever's closest to you to start and usually that's wood. so I wouldn't say any of these games are like MineCraft because of this however I do acknowledge none of these would exist if there was no MineCraft (don't imagen that terrible reality) If you think about it though there might not be any platformers if there was no Mario and the whole of first-person shooters used to be could by "Doom clones"

    And for SlimeRancher2 I have played that and didn't notice that my game and it's graphics do kind of look similar of course their game has much better lighting. which I do plan to improve my lighting.
     
    Last edited: Apr 1, 2024
  13. StarSilver22

    StarSilver22

    Joined:
    Aug 7, 2022
    Posts:
    28
    Week 9
    The first thing I did this week was change the health and death script which I use on basically everything in the game the player, trees, sticks, rocks, and tools. This way everything can be destroyed. The problem with the script was that every single thing in the game checked if it had hp regen (rocks and tools would not) and if it did it checked if it was time for it to regen, and as anybody could see this is a problem (except me lol) so what I did now is that if something takes damage it checks if it has hp regen, and if it does it starts a coronatine that waits then updates the hp then deactivates after hp gets to the max.

    the other thing I did was documentation (this is how you use the word right?)
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class HealthAndDeathScript : MonoBehaviour
    6. {
    7.     public enum DamageTypes {Bludging, Slashing, Pircing, Burning, Frezzing, posining, lightning}
    8.    
    9.     [SerializeField] DamageTypes[] damageAmunitys;
    10.     public float maxHP = 100f;
    11.     public float hp;
    12.     [SerializeField] float timeWaitingForRegen;
    13.     public float natralHPRegenSpeed = 10f;
    14.     public float natralRegenAmount = 3f;
    15.     [SerializeField] bool hasNatralRegen;
    16.     public GameObject[] itemsTooDrop;
    17.     public Vector3[] itemDropPos;
    18.     public Quaternion[] itemDropRotation;
    19.  
    20.     private void Start()
    21.     {
    22.         hp = maxHP;
    23.     }
    24.  
    25.  
    26.     IEnumerator UpdateHealthRegen()
    27.     {
    28.         if(hp < maxHP)
    29.         {
    30.             while (hp < maxHP)
    31.             {
    32.                 timeWaitingForRegen += Time.deltaTime;
    33.                 yield return null;
    34.                 if (timeWaitingForRegen > natralHPRegenSpeed)
    35.                 {
    36.                     Heal(natralRegenAmount);
    37.                     timeWaitingForRegen = 0;
    38.                 }
    39.             }
    40.         }
    41.        
    42.     }
    43.  
    44.     public void Heal(float healAmount)
    45.     {
    46.         hp += healAmount;
    47.         if(hp > maxHP)
    48.         {
    49.             hp = maxHP;
    50.         }
    51.     }
    52.  
    53.     public void Damage(float damage, DamageTypes damgeType)
    54.     {
    55.         for(int i = 0; i < damageAmunitys.Length; i++)
    56.         {
    57.             if (damageAmunitys[i] == damgeType)
    58.             {
    59.                 damage = 0;
    60.             }
    61.         }
    62.         hp -= damage;
    63.         if (hasNatralRegen)
    64.         {
    65.             StartCoroutine(UpdateHealthRegen());
    66.         }
    67.         if (hp <= 0)
    68.         {
    69.             Die();
    70.         }
    71.     }
    72.  
    73.     void Die()
    74.     {
    75.         for(int itemsDroped = 0; itemsDroped < itemsTooDrop.Length; itemsDroped ++)
    76.         {
    77.             Instantiate(itemsTooDrop[itemsDroped], gameObject.transform.position + itemDropPos[itemsDroped], itemDropRotation[itemsDroped]);
    78.         }
    79.         Destroy(gameObject);
    80.     }
    81.  
    82.     private void OnTriggerEnter(Collider other)
    83.     {
    84.             gameObject.transform.SetParent(other.transform);
    85.     }
    86. }
    87.  
    this is what it looked like before

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class HealthAndDeathScript : MonoBehaviour
    6. {
    7.     //the types of damage (other scripts will acsess this in order for damage types to be consistent)
    8.     public enum DamageTypes {Bludging, Slashing, Pircing, Burning, Frezzing, posining, lightning}
    9.    
    10.     //the damage this gameobject are amune to
    11.     [SerializeField] DamageTypes[] damageAmunitys;
    12.     // stats for hp regen
    13.     public float natralHPRegenSpeed = 10f;
    14.     public float natralRegenAmount = 3f;
    15.     float timeWaitingForRegen;
    16.     [SerializeField] bool hasNatralRegen;
    17.     //hp and max hp
    18.     public float maxHP = 100f;
    19.     public float hp;
    20.     //items to drop on death where they spawn and the rotation they spawn at
    21.     [SerializeField] GameObject[] itemsTooDrop;
    22.     [SerializeField] Vector3[] itemDropPos;
    23.     [SerializeField] Quaternion[] itemDropRotation;
    24.  
    25.     private void Start()
    26.     {
    27.         //set hp to max at start of game
    28.         hp = maxHP;
    29.     }
    30.  
    31.  
    32.     IEnumerator UpdateHealthRegen()
    33.     {
    34.         if(hp < maxHP)//check if the coroutine is nesecery
    35.         {
    36.             while (hp < maxHP)
    37.             {
    38.                 //while not at the max hp update time waiting
    39.                 timeWaitingForRegen += Time.deltaTime;
    40.                 //wait one frame so the game doesn't crash
    41.                 yield return null;
    42.                 if (timeWaitingForRegen > natralHPRegenSpeed)
    43.                 {
    44.                     //if the time waiting is higher then the time to wait heal and set time waiting to zero
    45.                     Heal(natralRegenAmount);
    46.                     timeWaitingForRegen = 0;
    47.                 }
    48.             }
    49.         }
    50.        
    51.     }
    52.  
    53.     public void Heal(float healAmount)
    54.     {
    55.         //heal then make sure hp is below max
    56.         hp += healAmount;
    57.         if(hp > maxHP)
    58.         {
    59.             hp = maxHP;
    60.         }
    61.     }
    62.  
    63.     public void Damage(float damage, DamageTypes damgeType)
    64.     {
    65.         for(int i = 0; i < damageAmunitys.Length; i++)// for every type of damage this game object is amune to check if it's been hit by that damage and if so take no damage
    66.         {
    67.             if (damageAmunitys[i] == damgeType)
    68.             {
    69.                 damage = 0;
    70.             }
    71.         }
    72.         hp -= damage;
    73.         if (hasNatralRegen)// start hp regen if game object has it
    74.         {
    75.             StartCoroutine(UpdateHealthRegen());
    76.         }
    77.         if (hp <= 0)//die if is dead
    78.         {
    79.             Die();
    80.         }
    81.     }
    82.  
    83.     void Die()
    84.     {
    85.         //drop all items too drop before death
    86.         for(int itemsDroped = 0; itemsDroped < itemsTooDrop.Length; itemsDroped ++)
    87.         {
    88.             Instantiate(itemsTooDrop[itemsDroped], gameObject.transform.position + itemDropPos[itemsDroped], itemDropRotation[itemsDroped]);
    89.         }
    90.         Destroy(gameObject);
    91.     }
    92.  
    93.     private void OnTriggerEnter(Collider other)// the chunks have triggers so sets to be a child of the chunk its in
    94.     {
    95.             gameObject.transform.SetParent(other.transform);
    96.     }
    97. }
    98.  
    and this is now maybe it's a bit over kill, but I don't know if future me will get hit in the head really hard or not. Or if I'll end up needing someone else to work on this script. Future me could also just forget.

    I should have documented it while making it instead of waiting two months, but I've got most my scripts done now.

    So, this week will probably be mostly the same thing.
     
    developer3244 likes this.
  14. developer3244

    developer3244

    Joined:
    Jan 4, 2024
    Posts:
    88
    You could add some building layer for make game more interactive, and make a small playable demo for show what your game is about. Also, unity learn itself have stuff for help you to learn how to make better performace in heavy games, particulary for optimize to mobile (consider that my desktop is almost a mobile because is kinda slow). I know it seems that im weirdly hyped, but your game idea seems cool :)
     
    StarSilver22 likes this.
  15. StarSilver22

    StarSilver22

    Joined:
    Aug 7, 2022
    Posts:
    28
    Week 10
    This week I finished documenting all of my script
    except a few I forgot how they worked (there not being used anyway) Plus the terrain gen scripts I used youtube to make them so I can re-watch that if I need too

    Some irl stuff came up so I haven't had time too work vary much this week but things are looking good

    And thanks to developer3244 the feed and encouragement is appreciated a demo isn't vary possible for a while (unless you want to walk around and chop down trees and thats it)

    There was also a solor eclipse in my area that was cool:)

    Next goals are more crafting modeling and Ai(which I'm excited and slightly scared about making)
     
  16. developer3244

    developer3244

    Joined:
    Jan 4, 2024
    Posts:
    88
    Yes, a total solar one, a very rare one you dont see always... this didnt happened where i leave, and even if it does, i would see only a very cloudy sky ;)

    About AI, i guess you mean enemies that are AI based, that can attack player, etc. If yes, i found stuff with one of my best friends Copilot:

    The Science Behind Game AI: Understanding the Algorithms and Techniques (trailyn.com)
    Enemy AI in Unity - Game Dev Beginner
    https://docs.unity3d.com/2020.3/Documentation/Manual/Navigation.html (that one was me only)

    also, i found an interessing channel with good videos: (5) FULL 3D ENEMY AI in 6 MINUTES! || Unity Tutorial - YouTube (just ignore the less recent ones, some are just nothing usefull)
     
  17. developer3244

    developer3244

    Joined:
    Jan 4, 2024
    Posts:
    88
    More cool videos i found made by a popular yt one:





     
  18. developer3244

    developer3244

    Joined:
    Jan 4, 2024
    Posts:
    88
  19. developer3244

    developer3244

    Joined:
    Jan 4, 2024
    Posts:
    88
  20. StarSilver22

    StarSilver22

    Joined:
    Aug 7, 2022
    Posts:
    28
    Week 11
    This was a slower week then I wanted but sometimes we don't get to choose *sigh*
    Anyway, mostly what I've done is research what type of ai (for the animals) a problem I saw fast was that I can't use navmesh agents because they have to be baked before run time. Problem is I make the map on run time see as the world is procedurally generate that can't really be changed.

    I'm pretty sure a can use recasts to determine movement.

    This is the structure I'm going for the ai, so there will be dens and each den will have a set number of animals living in them and it will randomly place animals around it. Then the animals will have short and long term memory which will each have a limited amount of space (long term obviously more than short) and so if they encounter a new animal they've never seen before they'll assess the situation then based on past experiences and personality trats (such as being fear full or carefree)

    Say if they see a bigger animal then them and they don't have any memories of this type of animal. But they have a memory of something bigger than them say the player and the player choose to feed them they might investigate farther but Thay could also be fear full, so they just watch and if the thing sees them and goes towards them at a faster speed then Thay like they'll run away. then they'll have a memory of this and when Thay go back to their den they'll tell the others there and when Thay sleep short term memories transfer to long term.

    Defiantly vary ambitious but the games about the environment so I'm going to go big on the animal AI.

    so, this week that's what I'm doing continuing on animal Ai.:D
     
  21. developer3244

    developer3244

    Joined:
    Jan 4, 2024
    Posts:
    88
    You should keep shorter, as i understood you want a real AI that have reinforcement learning capatibilities, and reinforcement learning isnt easy task for beginers. Unless you already have experience in unity and AIs, do something smaller or you will not finish this game if keeping ambitious stuff in.

    Did you mean raycasts?
     
  22. developer3244

    developer3244

    Joined:
    Jan 4, 2024
    Posts:
    88
    This week was slower... usually my ones always have a fixed time of 7 days, but i guess i know why yours not. By coding good stuff i guess the reason of your slower week is that you made a hole in reality that caused the earth spin faster and cause a smaller week. lol
     
  23. StarSilver22

    StarSilver22

    Joined:
    Aug 7, 2022
    Posts:
    28
    Yes I meant raycasts.

    You should keep shorter, as i understood you want a real AI that have reinforcement learning capatibilities, and reinforcement learning isnt easy task for beginers. Unless you already have experience in unity and AIs, do something smaller or you will not finish this game if keeping ambitious stuff in.

    I didn't quit mean full machine learning think RainWorld (if you've played that) which saying that makes it sound very ambitious. but I do feel the game will benefit from this I will keep in mind that by no means am I a professional and I will cut corners on the ai where I can but as far as I know none of the other things, I've got planed are scope creep.

    This week was slower... usually my ones always have a fixed time of 7 days, but i guess i know why yours not. By coding good stuff i guess the reason of your slower week is that you made a hole in reality that caused the earth spin faster and cause a smaller week. lol

    o_O All I meant was I couldn't work as much as I wanted last week lol
     
    Last edited: Apr 16, 2024 at 3:50 PM
  24. developer3244

    developer3244

    Joined:
    Jan 4, 2024
    Posts:
    88
    Well never played...

    ok so XD

    Well if you is confident you can do AI stuff, lets see how you manage that