Search Unity

Games Yet another Garden - Farming game

Discussion in 'Projects In Progress' started by drizztfun, Sep 8, 2013.

  1. drizztfun

    drizztfun

    Joined:
    Jul 2, 2013
    Posts:
    25
    hi there,

    yes yes, another farming game, i know there are plenty out there ;)

    But i was just looking for something as a first game project where i can learn the basics and maybe a bit more of unity.

    As usually you can plow the ground, plant seeds, water them and finally, harvest.
    Also you can place a house, a little water well which is required for watering and some decorations, like a fence or wall and trees, surrounding your little garden.

    The area is a voxel-terrain (thanks to Voxeland, great project :)) which gives the player the chance to shape everything to his/her own liking. Like making some hills or just dig into the ground to make a little lake etc.

    My biggest weakness, apart from my mediocre programming skills, is my artwork. Its limited to the skill of a untalented 3 year old and so you will see pretty good artwork, but sadly its not from me. I just fail to create anything more complex than a cube.

    Well, words are just words, have a look at the video i made from actual gameplay and give me some *honest* feedback please.

    Thank you!

     
    krougeau, shkar-noori and jamnyan15 like this.
  2. FlyingAce

    FlyingAce

    Joined:
    Jan 12, 2013
    Posts:
    58
    Wow, this looks awesome! All the art works together, the voxel terrain integration is phenomental! And everything seems to have some polish on it even though it's unfinished. You should be proud of your work! :) My only suggestions would be to add more terrain to the world (it looks a bit flat) and to introduce some sort of antagonist to the game, like wolves, or disease, or a count down clock, unless it's a really casual game like farmville, then farm away! Great job
     
  3. drizztfun

    drizztfun

    Joined:
    Jul 2, 2013
    Posts:
    25
    Thank you for the fast feedback! :)
    Yes i am working on that for a bit already, but i was just shy to show it before because.. it did not feel good enough yet.

    Maybe i should add some more information:
    - there is music in the game, just one thing, but at least something
    - very few sound effects (walking, plowing)
    - facebook-integration is working partially, you can login with facebook or user/password
    - ah yes, its a webplayer game

    Some technical information:
    The whole game is a client/server game. Game logic is mostly on the server, client is doing only basic pre-checks. So your progress including changed terrain is stored on a server. (through web api, server is in c# with entity framework for the database)
    Data transfer is done with JSON except the terraindata which is just a binary transfer to reduce the webtraffic.

    Currenty i am working on the friend-feature. You can already visit friends and help them in the garden. Those rights adjustable for each action like visiting, harvesting, plowing etc.
    In addition you can make your garden accessible to public and also adjust some rights for it. So everybody could visit and help harvesting if you want that. There is some "portal", if you step into it, you will be teleported to a random garden if its open to public.

    $FriendInterface.jpg

    What is missing .. erm.. adding friends ;) I am just not sure how to handle it best. Players coming from facebook could see a facebook-friend-list.. but what about those who play directly. Add by login-name or email maybe?

    @flyingAce
    Yes, you are right, i need to put a bit more variation into the surrounding area, i will work on that.
    And some animals should be added. There is just a chicken now which can chased through the farm if you get too close. Heh.. well i felt a bit playful when i implemented that.

    I want it to be mostly casual, but with some extra on it. Maybe if you don't care for your plants some nasty things could grow? Still thinking :)
     
  4. virror

    virror

    Joined:
    Feb 3, 2012
    Posts:
    2,963
    Looks impressive!
    As FlyingAce said, very polished feel even though its not ready yet.
     
  5. primus88

    primus88

    Joined:
    May 14, 2013
    Posts:
    611
    This game is very well done. Congratulations. I can see a lot of work went in it.
    Was this your first project overall or only in Unity ?
     
  6. drizztfun

    drizztfun

    Joined:
    Jul 2, 2013
    Posts:
    25
    Thank you!

    Well i do have a pretty solid programming background, but only business applications, nothing with games or even graphics and also only in Delphi/Pascal.

    So i am 100% new to game development, unity and C# .Net/Mono and also web technology as i used with the server.

    But yes i know how to do object oriented programming, structure a project, access a database and such things.
     
  7. jamnyan15

    jamnyan15

    Joined:
    Nov 25, 2014
    Posts:
    1
    hey uhmmm I am wondering if you have tutorials about making a game like that (growing trees, harvest plants and others related to garden game) please we need your help.
     
    thesis2k18 likes this.
  8. drizztfun

    drizztfun

    Joined:
    Jul 2, 2013
    Posts:
    25
    hi

    wow somebody really dug up that old thing ;)

    To be honest its on hold since a longer while because the webplayer did not seem to have a future. Maybe i will continue now with web gl.. have to see how much effort the move to Unity 5 will be ;)

    But to your question.. no. sorry. i dont have any tutorial. And since this is/was my first game, i have serious doubts it would be a good source for a tutorial. Its just everything but well documented and witten in clean code ;)

    My approach was rather simple.. i have different prefabs for the plants, for the growing stages. The growing stage is being calculated from the progress in %. So if it needs 1 hour to grow and it has been planted 12 minutes ago that would put as at 20% progress.

    Well and so on.. if you have any specific quetsion, feel free to ask. Because explaining the whole system here is a bit too much i guess ;)
     
  9. greg4612

    greg4612

    Joined:
    Apr 6, 2015
    Posts:
    1
    Hello is there a way that you could explain to me how you did the plant and picking features?
     
  10. grka

    grka

    Joined:
    Jan 14, 2015
    Posts:
    80
    Too sad, I had the very same question like greg4612. I would like to have something like that in my game too with creating a field-square, planting some pants and picking the features but I can't find any tutorial which explains how to do that
     
    thesis2k18 likes this.
  11. drizztfun

    drizztfun

    Joined:
    Jul 2, 2013
    Posts:
    25
    Well about which aspect do you want to know something?
    Its a unity-client with a REST-Webservice which is handling all the data and storing it in a mssql-database.
    The client is rather "stupid", handling only userinteractions and giving all actions to the server for processing and verification. This happens in a background "thread" meaning all useractions is being queued and then processed while the user is still working the farm.
    Well if you have a bad connection it could happen that your last x actions are not saved and you have to do it again after reconnecting.

    What exactly is the question from both of you?
    How to handle user interaction? How to save/process the planting/harvesting data on the database? etc.
     
  12. grka

    grka

    Joined:
    Jan 14, 2015
    Posts:
    80
    Thank you for the reply. I have a farm game with animals which has a mysql connection to a webserver too and the most logic is on the server as well, so I know how to handle this part. For me Unity3D is still very new and I still try to find out how things are handled. I have a 3D world, it's an island, with alot of grass area.

    I would like to know how to create this entire thing about placing a square with the mouse where the new plants shall grow (0:11 min in the video), seeding the plants and then let them grow and later harvest them. So far I managed this: I changed the texture from my grass to something else and when the user clicks on it I discover that he clicked on the "farm-field-texture". But instead I would prefer to place the field-square more dynamiclly like in your video. What kind of game objects do I need? e.g. Are these squares prefabs that are instansiate when you place them? How can I display on the ground where they are placed while the user is moving it's mouse and drags the square tile around? How do I avoid to place to squares at the same place? how do I create a plant that grows. I hope you understand what I mean. It's more the unity side that I would like to understand.
     
    Last edited: Jun 1, 2015
  13. grka

    grka

    Joined:
    Jan 14, 2015
    Posts:
    80
    If it's too difficult to explain maybe it's possible to make a small demo project (without server connection and all this) where you can just place these field tiles, putting one static plant seed on it and let the plant grow. Mayxbe that's easier
     
  14. drizztfun

    drizztfun

    Joined:
    Jul 2, 2013
    Posts:
    25
    oh i see.. no i dont change texture or anything. i did a more simple approach.
    the planted/plowed field is just a prefab, some plane or simple mesh with the groundtexture.
    So i have 1 prefab for an empty field, one for pumpkins at tiny grow state, medium, full grow state etc. and that again for every kind of plant etc. i want to put. So its really just putting a prefab there and removing old one before eventually.
    I have a simple array, lets say 10*10 for all the fields, and for each field i maintain the information as:
    - plowed?
    - watered? (faster growing)
    - what seed is planted, if any
    - when was it planted
    - whats the total growth time in seconds. that one is modified by watering etc.
    - game object reference to patch!

    When the user clicks the terrain (raycasts should ignore the patches+plants), you get the absolute coordinate of the click. You know the offset from (0/0/0) where your farm starts, you know the size of each patch. With this information you call a routine, giving it the x/y patch coordinates, NOT the mouse coordinates anymore.
    And that routine knows the before mentioned array, it can see whats the current state, change cursor on mouseover and on a click it can harvest, or plant. Since your array holds the gameobject reference, you can just destroy the old patch before putting a new one.i constantly check in update() if planted/plowed time + total growth time is now(). and then i know its ready to harvest. if growing time is 1 hour and it was planted 2 hours ago for example, i let it wither/rot away ;)
    In fact i do those calculations on the client, too. Just when an action is executed, i ask the server, the server computes again and says ok or not ok. otherwise it would be too much communication with the server.

    The prefab moving when planting/plowing is also just done by the routine mentioned before. convert mouse coordinates to field coordinates, then convert back to placement coordinates of the "tile/patch" and change coordinates in update().

    I dont have access to the sources right now, so thats all i can tell you from my memory ;) Around the weekend i could dig up the source to lookup things if you have more questions.

    or to sum it up: :)
    1. make routine mousecoordinate to field x/y
    2. field coordinate to unity coordinates for placing
    3. make the array with field information

    play around with those, it should get you started properly
     
  15. grka

    grka

    Joined:
    Jan 14, 2015
    Posts:
    80
    Thank you very much, this helps me already a lot. One more question about these mouse, field and placement coordinates: Did you put some grid over the entire terrain and work with these coordinates or why are they different and need some converting?
     
  16. drizztfun

    drizztfun

    Joined:
    Jul 2, 2013
    Posts:
    25
    Well you could use the unity system 1:1 ..but that would make your patches exactly 1x1 in size. i wanted to be more flexible and especially i support different sizes of patches. the ones in the video are the large ones, there are also smaller ones where you can put 4 small instead of 1 big.

    About the converting. for clicking purpose you want to focus on the center of the patch. So if your patch size is 1x1 then the center would be at 0,5 / 0,5. otherwise the mouse movement will be weird at best.

    but for my patches i needed to put it at 0/0 if i want it to be from 0/0 to 1/1.

    thats my first project in unity.. i did not know about pivot and changing ;)) so i had to do it this way.

    So please about all i told you.. thats the way i did it, its a way which works, but its maybe not the best approach.

    to clarify : if you click anywhere from 0.1 to 1.0 then the converter has to make a straight 1 of it so you can work with your array. and if your patch is 1.5 in size, then any click from 0.1 to 1.5 must result in a 1 for same reason.
    keep the factors in variables or constants, dont put them hardcoded anywhere. you might want to adjust the size later on.
     
  17. grka

    grka

    Joined:
    Jan 14, 2015
    Posts:
    80
    Thank you that has help me already a lot :)
     
  18. grka

    grka

    Joined:
    Jan 14, 2015
    Posts:
    80
    Can I ask you something more please? So far I have a plane that I can drag&drop around my area and place it where I want. I have 2 problems now:
    1. my planes can overlap each other and the collision detection isn't working even though each plane has a collider box and rigidbody.

    2. In your video it seems that your squares are only following an invisible grid during the dragging and can placed only there. How did you do that? How do you avoid that 2 squares are in the same place?

    My Drag Script looks like that right now:
    Code (CSharp):
    1. void OnMouseDrag ()
    2.     {
    3.  
    4.         float distance_to_screen = Camera.main.WorldToScreenPoint(gameObject.transform.position).z;
    5.         Vector3 pos_move = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, distance_to_screen));
    6.  
    7.         // keep the plane over the ground
    8.         float y = MyTerrain.SampleHeight(pos_move)+0.5f;  
    9.      
    10.         transform.position = new Vector3(pos_move.x, y, pos_move.z);
    11.      
    12.     }
    13.     void OnMouseDown ()
    14.     {
    15.         this.GetComponent<Rigidbody>().isKinematic = false;
    16.     }
    17.  
    18.     void OnMouseUp ()
    19.     {
    20.         this.GetComponent<Rigidbody>().isKinematic = true;
    21.     }
     
  19. drizztfun

    drizztfun

    Joined:
    Jul 2, 2013
    Posts:
    25
    We are totally leaving the focus of this WIP-Forum :p

    If you want to know more we should continue in another forum, so that people here dont get spammed by things they dont want to see ;)

    As i said before.. do NOT use the mouse coordinates immediately.. convert them into grid coordinates first. Then you can verify what is in there.. thats what i used to make the movable prefab go red as a warning "cant place".
    After that convert the grid-coordinates back into world-coordinates.

    1. So lets say you click at 1.3 , 1.7 (height is irrelevant now)
    2. then your first routine will tell you.. that is Field 1, 2 for example. Now you check the status in ur array.
    3. now you convert that 1,2 into the placement coordinates for the field

    That way the prefab will properly jump like on a grid.

    So your transform.position will get the placement coordinates, not where the mouse really is.

    Believe me that is more fun if you do it on a voxel terrain and then you have to check the height, and if the ground patch is big enough etc. ;) but its doable, i did that too
     
  20. grka

    grka

    Joined:
    Jan 14, 2015
    Posts:
    80
    I sent you a private message
     
  21. GhostcatPNG

    GhostcatPNG

    Joined:
    Nov 17, 2020
    Posts:
    2
    Hello there, I am also making a 3rd person farming/gardening game! I would like to know if you could make a tutorial on how you did it. Farming is one of the main focuses of my game and if you did it would save my game! Please let me know if you do! - GhostcatPNG
    PS: I just learned if I want to do this with the asset store it would cost about $110! So I now know how helpful this could be.
     
  22. nomanmiy100

    nomanmiy100

    Joined:
    Apr 3, 2021
    Posts:
    1
    Tell me why I can't download this game