• Advertisement

Algorithm I need help in the creation of "tree felling"

Recommended Posts

I make a one game, and i want to do a sistem of tree feling, like in Lumber Tycon 2.But i do not know how do this.

If anyone has any ideas how to do this, please write!

Share this post


Link to post
Share on other sites
Advertisement

Start by breaking down the "system" in smaller pieces, then tackle each piece separately. (ie Divide and Conquer holds very much in computer programming).

 

For tree felling, start with having a tree, and displaying it. If "displaying it" is too complicated for you, study how to display 3D objects first (ie again apply Divide and Conquer).

With a displayed tree, add making a cut at some point in the tree, and splitting a tree in 2.

Then add physics so the tree (or parts of it) fall down as you'd expect.

 

Share this post


Link to post
Share on other sites

Thanks, but i want the tree to split up where the character beats,that is, the vertices of the cut appear where the character beats.(Look at Lumber Tycon 2 in Roblox) 

Share this post


Link to post
Share on other sites
1 hour ago, Nierkool said:

Thanks, but i want the tree to split up where the character beats,that is, the vertices of the cut appear where the character beats.(Look at Lumber Tycon 2 in Roblox) 

Re-read @Alberth post. What have you achieved so far? Can you display a tree? 

There's no point in people going into a detailed discussion of how to break up a tree if they don't know your starting point.

Share this post


Link to post
Share on other sites
Posted (edited)
10 hours ago, Nierkool said:

Thanks, but i want the tree to split up where the character beats,that is, the vertices of the cut appear where the character beats.(Look at Lumber Tycon 2 in Roblox)

Then you also saw the little crosshair that points to that position.

 

Staring at the total picture and then expecting you will find a solution is not going to work, it's just too big to comprehend. The only working tactic I found so far is what I said, decompose into smaller sub-problems until they seem solvable, then solve each sub-problem.

Edit: Thus if my second step is not solvable for you, decompose it further.

Edited by Alberth

Share this post


Link to post
Share on other sites

Ok.Then the last question:how to divide an object into two parts during the game?

I know how this should happen, but the problem is that I can not write this script.
 

Share this post


Link to post
Share on other sites
Posted (edited)

You need to know that cutting a object for real isn't only difficult but games don't like doing it in real time; that is why Metal Gear Rising was so special when it released.

Often breaking objects in games is fake. The object is replaced by broken pieces that don't actually break realistically.

So the question is do you want the "Fake" or "Cut" way of doing this.

 

To Fake it.

Create your tree model. Then make broken tree parts. When the tree is hit, just destroy it and load in the broken pieces.

 

To Cut it.

Make the tree model.

Most commonly a ray trace is done to slice the mesh. The points where the mesh intercepts is calculated using vector math. Using these stored points and the original mesh you make two new meshes. You need to know VectorsDotProduct and CrossProduct to do this.

After the two new meshes is made you need to fill any holes because meshes are just shells, You also need to calculate there UV map again. The filling should also be UV mapped.

Apply physics to the new meshes and done. Don't keep them in the memory long because these kinds of meshes can quickly use up resources.

 

Edit:

Looking at Lumberyard Tycoon, they faked it. The model isn't 1 model it is lots of small models and when you hit one it breaks at that point.

So where it breaks was decided before you chop the tree.

Edited by Scouting Ninja

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Advertisement
  • Advertisement
  • Popular Tags

  • Advertisement
  • Popular Now

  • Similar Content

    • By 3dmodelerguy
      So I am building a turn based rogue-like (think CDDA). The game is going to have a very large map (up to 1000's x 1000's) however to alleviate most of that I obviously can't render everything so there will just be render a certain radius around the player and just load in and out data as the player moves.
      The next major system I am prototyping is making interactive tiles destructible and pretty much everything will be destructible besides basic landscape (cars, doors, windows, structures, etc. will be destructible)
      While I am only rendering a certain amount of tiles around the player, I want to keep the amount of colliders active at one time to be as small as possible for performance and currently the tilemap tool I use automatically merges colliders together.
      So instead of creating a separate colliders for each of these tiles and having the destructible behavior tied to that object (which my tilemap tool would allow me to do) I was thinking that I would store an array of all the X and Y locations for the interactive tilemap layer and let the tilemap manage the colliders. 
      Then when I hit a collider on the interactive tilemap layer, instead of of getting the behavior for how to deal with the destruction for that tile from that game object, I would pull it from the array I mentioned earlier based on the tile I attempt to interact with which I already have.
      Does this sound like a good approach? Any other recommendations would be welcomed.
    • By Katie Byrne
      F.OB: Forward Operating Base is a military themed base building and resource management game.

      I am currently about 6 weeks into development. still implementing core game mechanics. The game is playable in a basic sense right now but there are no objectives or missions or anything motivating really lol. 

      I have been inspired by games such as prison architect and rimworld. both in visual style and general gameplay ideas. Here is a quick 2 minute video i put together that hopefully communicates the general feel of the game and what gameplay is like. Any feedback or criticism is welcome
       
       
      I have been keeping a development diary on my youtube channel and i hope to have more developments on this project very soon. 


       
    • By NDraskovic
      Hey guys,
      I have a really weird problem. I'm trying to get some data from a REST service. I'm using the following code:
       
      private void GetTheScores() { UnityWebRequest GetCommand = UnityWebRequest.Get(url); UnityWebRequestAsyncOperation operation = GetCommand.SendWebRequest(); if (!operation.webRequest.isNetworkError) { ResultsContainer rez = JsonUtility.FromJson<ResultsContainer>(operation.webRequest.downloadHandler.text); Debug.Log("Text: " + operation.webRequest.downloadHandler.text); } } The problem is that when I'm in Unity's editor, the request doesn't return anything (operation.webRequest.downloadHandler.text is empty, the Debug.Log command just prints "Text: "), but when I enter the debug mode and insert a breakpoint on that line, then it returns the text properly. Does anyone have an idea why is this happening?
      The real problem I'm trying to solve is that when I receive the text, I can't get the data from the JSON. The markup is really simple:
      [{"id":1,"name":"Player1"},{"id":2,"name":"Player2"}] and I have an object that should accept that data:
      [System.Serializable] public class ResultScript { public int id; public string name; } There is also a class that should accept the array of these objects (which the JSON is returning):
      [System.Serializable] public class ResultsContainer { public ResultScript[] results; } But when I run the code (in the debug mode, to get any result) I get an error: ArgumentException: JSON must represent an object type. I've googled it but none of the proposed solutions work for me.
      Also (regardless if I'm in the debug mode or not) when I try to do some string operations like removing or adding characters to the GET result, the functions return an empty string as a result
      Can you help me with any of these problems?
      Thank you
    • By mister345
      Hi guys, so I have about 200 files isolated in their own folder [physics code] in my Visual Studio project that I never touch. They might as well be a separate library, I just keep em as source files in case I need to look at them or step through them, but I will never actually edit them, so there's no need to ever build them.
      However, when I need to rebuild the entire solution because I changed the other files, all of these 200 files get rebuilt too and it takes a really long time.
      If I click on their properties -> exclude from build, then rebuild, it's no good because then all the previous built objects get deleted automatically, so the build will fail.
      So how do I make the built versions of the 200+ files in the physics directory stay where they are so I never have to rebuild them, but
      do a normal rebuild for everything else? Any easy answers to this? The simpler the better, as I am a noob at Visual Studio settings. Thanks.
    • By nihitori
      The Emotional Music Vol. I pack focuses on beautiful and esoteric orchestral music, capable of creating truly emotive and intimate moods. It features detailed chamber strings, cello and piano as the main instruments, resulting in a subtle and elegant sound never before heard in video game royalty-free music assets.

      The pack includes 5 original tracks, as well as a total of 47 loops based on these tracks (long loops for simple use and short loops for custom / complex music layering).

      Unity Asset Store link: https://www.assetstore.unity3d.com/en/#!/content/107032
      Unreal Engine Marketplace link: https://www.unrealengine.com/marketplace/emotional-music-vol-i

      A 15 seconds preview of each main track is available on Soundcloud:
       
  • Advertisement