Home Unreal Engine

[UE4] Need some Blueprint help - Making a fence that deforms to terrain

ngon master
Online / Send Message
ZacD ngon master

Hey guys, hopefully some of the more tech artist minded people here can help out with this one.

I'm trying to make a procedural fence I can use for one of my projects. I made an example video and sudo blue prints of how I'd imagine this would work, but I'm having trouble figuring exact which nodes I'd use, and how to setup a proper looping function. 

Also is it possible to bake down a mesh created from blue print construction scripts into a static asset? Because I'd only need the procedural generation during iteration and blocking out the scene. 

So here's the examples of what I'd like to do exactly.

http://youtube.com/watch?v=lKWV3qfNTHQ




The furthest I've gotten on my own is placing a post every 500 cm at where it intersects with the terrain, but that's lacking pretty much everything I want to do with this.

In the future I want to build in parameters that allow the fence to curve a few degrees every post, allow you to ease in and out of curves, have drop down menus to pick the starting an ending pieces, add forward/backwards sagging, pick rails/posts out of a pool of assets and apply random 180 rotations and flipping on 2 axis, and having a rare pool of assets for damaged or more unique details.

The biggest issue I'm facing at the moment is how to do the arc trace, because I'm not seeing mentions of anything like it in tutorials or documentation. 

Then the next biggest issue I have is trying to make this whole thing loop x number of times.

Replies

  • Mossbros
    Offline / Send Message
    Mossbros polycounter lvl 9
    Sorry if its clearly not the right answer, but can you not use something like the UE4 blueprint spline for this?
    If you want the mesh to change randomly you could just pull a selection from an array. 
    That's how I would botch it anyway.
  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    Baking down is not possible. But otherwise its possible.. I've done this for multiple purposes so it surely works but unfortunately I'm not allowed to show you the script so I'll try to explain. Spline mesh would bend\distort your mesh, probably even after some tangent magic. Try this:
    have a spline - not spline mesh. On construction script, check the length of the spline. You need this because youll want to evenly distribute the poles along the spline. This will also tell you how many poles you can have. Basically any divider of the length. You can also floor\ceil\round the length to get a whole number. So then, put a for or for each loop depending on how you want it... Then on the loop update, do a line trace that goes straight downwards so you trace the surface of the terrain. On each loop, youd get location along the spline at distance and that distance would depend on the index of the loop multiplied by the desired distance of the poles so you can have even steps...on the inpact point, add an instance to an instanced static mesh (instances are free you can have thousands without any impact on the performance...) . You can do a similar thing to place the horizontal planks as well. Let me know how it goes, good luck!

    In the worst case I can make a new one and I can show you.
  • Froyok
    Offline / Send Message
    Froyok greentooth
    Obscura said:
    Baking down is not possible.

    It's possible and even advised for complex blueprint to save computations in a shipping game (especially on heavily complex blueprint, like tree generation and so on). See : https://docs.unrealengine.com/latest/INT/Support/Builds/ReleaseNotes/2015/4_7/
    Blueprint Merge Tool

    You can now merge different Blueprints together using the new Blueprint Merge Tool.

    This tool shows a visual comparison of two Blueprints and assists you in combining them! It's great for merging versions of a single Blueprint that were modified by different team members.

  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    Froyok said:
    Obscura said:
    Baking down is not possible.

    It's possible and even advised for complex blueprint to save computations in a shipping game (especially on heavily complex blueprint, like tree generation and so on). See : https://docs.unrealengine.com/latest/INT/Support/Builds/ReleaseNotes/2015/4_7/
    Blueprint Merge Tool

    You can now merge different Blueprints together using the new Blueprint Merge Tool.

    This tool shows a visual comparison of two Blueprints and assists you in combining them! It's great for merging versions of a single Blueprint that were modified by different team members.

    I checked this out and this combines blueprints but it doesn't say that it will give you a baked down mesh asset - I guess thats what Zac meant.
  • Froyok
    Offline / Send Message
    Froyok greentooth
    There is an other tool for combining blueprints : "Merge Actors" - https://docs.unrealengine.com/latest/INT/Engine/Tools/DevTools/
  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    Now this one might do something, but we tried it at work earlier on a generated plant (bp) and it was crashing. But it was working fine when we tried to merge multiple meshes with it.
  • jonas_molgaard
    I just tried merging an actor which contained a ton of splinemeshes generated in a constructionscript, and it works fine. The stuff i was working on was a tree/vine generator based on L-systems which would track along geometry it hit along the way. Now the problem i face now, is how to build logic for that.

    Would this logic work? Do a linetrace forward (in the turtle moving direction) and check if it hit something. Then if it does, set a bool that it's on a surface, and adjust the position to that impact point and adjust the direction. Then in the next forward move (now parallel with the surface it hit) still do a normal trace forward and if not hitting anything, do a trace downwards towards the surface and if it hits, adjust the position and surface rotation.

    Im thinking this must be quite similar to those blueprints where you want your character to walk on curved surfaces...
  • musashidan
    Offline / Send Message
    musashidan high dynamic range
    Maybe not the answer you're looking for but this can be done quite easily in 3dsMax, for instance.

    Export the terrain to Max

    Conform a spline to the terrain

    Use path deform or similar to instance the fence section along the spline

    Export/Import a single fence section to UE

    Select all fence sections in Max and use Tom Shannon's script to copy the selected objects' transforms and names to clipboard

    Back in UE press CTRL+V

    Proxy cubes will be created at the exact locations of the fence sections

    Swap out the single fence section SM that you imported earlier

    Your entire fence as it was created/located in Max will be instanced in place of the proxy cubes.

    If you don't use Max then sorry for wasting your time. :)


  • jonas_molgaard
    Its cool. And always good to have several ways of doing things. Personally i was mostly interrested in the algorithm / procedural implementation though
  • musashidan
    Offline / Send Message
    musashidan high dynamic range
    Its cool. And always good to have several ways of doing things. Personally i was mostly interrested in the algorithm / procedural implementation though
    Yes, I certainly agree that it's always great to know several ways of doing things but, this is also procedural/non-destructive as the spline path/instanced fence sections can be changed at any time and quickly updated in UE.
Sign In or Register to comment.