Search Unity

  1. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  2. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  3. Participate with students all over the world and build projects to teach people. Join now!
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Easy Hills 2D (Bezier Curves Ground)

Discussion in 'Assets and Asset Store' started by langem, Dec 6, 2013.

  1. langem

    langem

    Joined:
    Mar 18, 2013
    Posts:
    73
    Hi everybody,

    I just released a new asset in the Asset Store. It's called Easy Hills 2D (Link)

    Ever wondered how the 2D physic-based hills are made? EasyHills2D provides all the functions to generate and edit these hills by yourself. For physics the hills use the new “Edge Collider 2D”. It’s really fast and guarantees a smooth sliding/driving on the hills. You can add decoration layers to the hills. This way you can generate grass or a road on the hills. EasyHills2D even allows you create destructible terrain that can be destroyed dynamically in your game!

    Features
    - Create 2D bezier hills in the Editor
    - Add decoration to the hills
    - Make the terrain destructible (y-direction only at the moment)
    - Terrain is generated dynamically at the beginning of a level (save space)
    - Full source code (C#)
    - Documentation and example scenes included

    Check out the documentation/step-by-step guide here: Documentation

    I really hope you like it and tell my if you have any questions or comments.
    Thanks and best regards,
    Matthias
     
  2. ProjectOne

    ProjectOne

    Joined:
    Aug 9, 2010
    Posts:
    442
    hi, interesting

    and... a few questions
    1) Can blocks of hills be removed (when scrolled outside the screen) and respwaned outside the screen (before they come on screen) to create a typical infinite runner level?

    2) is there any functionality demo-code with the package in the style of Tiny Wings, other?

    3) did you test it on iOS devices?

    4) draw calls? especially for iOS, mobile in general

    Thank you!
     
  3. langem

    langem

    Joined:
    Mar 18, 2013
    Posts:
    73
    Hi ProjectOne,

    thanks for your interest. About your questions:

    1) At the moment this functionality is not implemented. But it shouldn't be difficult to create an infinite with it. The segment can be easily recalculated and respawned at runtime. I'll think about adding this functionality in a future update.

    2) The package includes an example scene in the style of Tiny Wings. Of cause it's quite basic, but it works very well (a little ball accelerates downwards, if you touch the screen...)

    3) Unfortunatly I only tested it on Android devices. It runs very well there and I can't think about any reason it should not run on iOS. The segments are basically Meshes with Materials. So pretty standard stuff.

    4) The segments are batched (static) perfectly. A simple ground is drawn with one drawcall. If you add a decoration layer (road/grass or similar) it's two drawcalls. It's technically impossible to reduce both to one drawcall, because the textures have to be set to wrap mode = repeat. So you can't use texture atlases for the textures of the ground and the decoration. You can aswell adjust the vertex count of the segments to increase performance, but it runs very well even with hight vertex count settings.

    I hope that answers your questions and best regards,
    Matthias
     
  4. ProjectOne

    ProjectOne

    Joined:
    Aug 9, 2010
    Posts:
    442
    Excellent
    thank you for your answers,
    will buy it
     
  5. emeny2901

    emeny2901

    Joined:
    Jan 11, 2014
    Posts:
    1
    Hi

    you mention that the terrain is destructible only on the Y at the moment. Are there plans to add X as well and would this allow for creating more circular deformations like what's highlighted in the screenshot below?

    Thanks in advance

    $wormsarmpc_003-large.jpg
     
  6. langem

    langem

    Joined:
    Mar 18, 2013
    Posts:
    73
    Hi emeny2901, thanks for your interest. With the system used for the hill generation it's not possible to have worms like terrain deformation. The hills in Easy Hills 2D consist of triangle strips (vertices). Worms uses a pixel based approach I'd guess. Maybe I'll find a way to implement this feature in the future, but I can't promise anything. Best regards, Matthias
     
  7. Arsonide

    Arsonide

    Joined:
    Nov 16, 2009
    Posts:
    36
    Hello, langem. I created a component and attached it to one of the segments that simply adjusts the height of each point along the segment randomly. Afterwards I update the mesh.

    myNode.p1 = new Vector3(myNode.p1.x, Random.value*40.0f, 0.0f);
    myNode.p2 = new Vector3(myNode.p2.x, Random.value*40.0f, 0.0f);
    myNode.p3 = new Vector3(myNode.p3.x, Random.value*40.0f, 0.0f);
    myNode.p4 = new Vector3(myNode.p4.x, Random.value*40.0f, 0.0f);
    myNode.calculateMesh();

    For some reason this causes all segments, not just the one the component is attached to, to look identical sometimes. (Yes I've tried changing the seed.) Would you know why? The whole idea is that they look different from each other. Is there a step that I am missing?
     
    Last edited: Jan 19, 2014
  8. langem

    langem

    Joined:
    Mar 18, 2013
    Posts:
    73
    Hi Aronide,

    it has something to do with the meshRendere still using the same mesh as the other segements. If you copy the segments inside the editor a new mesh is automatically attached (See the Awake function in EasyHill2DNode.cs). If you do it code I think that you have to reset the mesh by yourself. Try to set: "myNode.meshFilter.mesh = new Mesh ();" before your code.

    Hope that helps and best regards,
    Matthias
     
  9. valan

    valan

    Joined:
    Oct 8, 2012
    Posts:
    9
    hello langem,

    i am doing a tiny wings clone which has slopes.
    i am rotating the sprite with the edge collider normals.
    it works fine if i use a sprite hill and a polygon collider, but does not work with the edge collider you are building on top of the mesh.

    what is the reason ?
    can u update me soon ?
     
  10. langem

    langem

    Joined:
    Mar 18, 2013
    Posts:
    73
    Hi valan, not sure if i understand your problem. In general only 2d physics are supported. And you can't mix 2d and 3d physics. Also only the edge collider is supported and not the mesh collider. It has a better performance. Hope that helps, Matthias
     
  11. valan

    valan

    Joined:
    Oct 8, 2012
    Posts:
    9
    Hi,
    I was using sprites and 2D polygon colliders for the game previously.
    And i was rotating the sprite to the normals, raycasting Physics.Raycast2D.
    It was working fine.
    Now I removed all the hill sprites and replaced with your HillObjects which has Edge colliders.
    Now I am not getting the normal properly, and the rotation is happening properly.
     
  12. valan

    valan

    Joined:
    Oct 8, 2012
    Posts:
    9
    Correction in the last line.

    Now I am not getting the normal properly, and the rotation is not happening properly.
     
  13. Tyrathect

    Tyrathect

    Joined:
    Jul 10, 2012
    Posts:
    38
    I'm using Unity 4.3.4 and I get a ton of compiler warnings. Could you please remove the causes of the warnings? They hide any warnings my own code may have.
     
    Last edited: Mar 16, 2014
  14. langem

    langem

    Joined:
    Mar 18, 2013
    Posts:
    73
    Thanks for the heads up. I'll have a look and fix it for the next update....
     
  15. McSteed

    McSteed

    Joined:
    Apr 26, 2014
    Posts:
    18
    Hello,

    I love Easy Hills. One thing I'm having trouble with:

    I'm using an overlap circle to test whether my motorcycle tire is on the ground. The overlap is only detected at the ends of each easy hill segment. Is that a problem with the edge collider? Or something with easy hills?

    Thanks,
     
  16. langem

    langem

    Joined:
    Mar 18, 2013
    Posts:
    73
    Hi McSteed,

    glad you like it :) About your problem. Without exactly understanding what your problem is I'd guess that it could be a problem with the edge collider. Is the "overlap circle" set to "trigger"? Otherwise weird stuff can happen ;) Why don't you check the ground collision with the normal circle collider of your wheels?

    best regards,
    Matthias
     
  17. McSteed

    McSteed

    Joined:
    Apr 26, 2014
    Posts:
    18
    I have a big issue - previous one solved :) - I docked the easy hills panel. Then I launched another project that didn't have the scripts installed. Errors popped up. Now the editor won't come up at all. It says its an Invalid panel.
     
  18. langem

    langem

    Joined:
    Mar 18, 2013
    Posts:
    73
    Hi there, that's normal behaviour. You'll find that with every other pugin that uses editor windows. The scripts have to be imported to each project you want to use it. Just close the window, import the scripts and dock the window again. Hope that helps, Matthias
     
  19. Buggz

    Buggz

    Joined:
    May 4, 2014
    Posts:
    2
    Hello,
    Im a beginner on Unity and I bought EasyHills 2D a few days ago, so far it looks great, I just have a few questions that you might be able to help me with, here goes :

    - I have an AI following my player on the hills , The Problem is everytime my main camera ( that follows the player ) goes to the next Segment, the Segment before disappears , which makes my AI fall because there is no ground anymore for him to stand on. How can I keep the segments visible when my player has already passed them ?

    - Also, I would like my AI to stay grounded all the time, meaning he does not jump after a Hill. Any way I can do that ? ( Im using rigidbody 2d and a Collider for the AI same as the player )

    - Last but not least, I cant seem to figure out how to make my player always go forward, meaning even if he is on a hill with very little speed, I do not want him to go backward on the hill but just keep going forward with very little speed.

    Thank you
     
  20. langem

    langem

    Joined:
    Mar 18, 2013
    Posts:
    73
    Hi Buggz,

    I'm glad that your like it. Your questions are not related to EasyHills 2D. It's about general Unity 2D problems:

    1. The segments are culled if they are not visible. That's a good thing because otherwise the performance would be very poor. That can't really be prevented to my knowledge. Try to have a "x-variable" for "AI" that holds the virtual x position if it is out of the screen.

    2. Try to use "Physics2D.Raycast" to get the ground position of your "AI". And then just put your "AI-sprite" to the calculated position.

    3. Set "rigidbody.velocity.x" to a min value if it is lower than this value.

    Hope that helps,
    Matthias
     
  21. McSteed

    McSteed

    Joined:
    Apr 26, 2014
    Posts:
    18
    Here's an Alpha version of the game I'm making with Easy Hills 2D.
    http://mcsteed.com/MotoMcSteed/index.html

    I have a request as well. It would be nice if there was a slot to add a 2D physics material on the hills at creation time.
     
  22. McSteed

    McSteed

    Joined:
    Apr 26, 2014
    Posts:
    18
    Unity 4.5 wrecks a lot of things including the textures on Easy Hills.
     
  23. langem

    langem

    Joined:
    Mar 18, 2013
    Posts:
    73
    Hi McSteed,

    what do you mean? It works fine. As usual (and specially with 4.5) Unity reimports the assets after the update. Some of the assets get reimported the wrong way (normal texture + wrap mode repeat becomes Sprite (2D\uGUI)). Just check the import options and everything should work fine.

    hope that helps and best regards,
    Matthias
     
  24. McSteed

    McSteed

    Joined:
    Apr 26, 2014
    Posts:
    18
    Thanks, I will try it again soon. It also made my Physics twitchy so I'm sticking with 4.3 for now. I'm too new it this to figure out what's going on.

    NEVERMIND: I got this one.
    I have a new request. Right now I'm adding a script to set the sorting layer. Is a built set up for that possible? I was going to try to add it to your script myself but I couldn't figure out where it would go.


    Thanks

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class SortingLayer : MonoBehaviour {
    5.  
    6.     // Use this for initialization
    7.  
    8.  
    9.        
    10.         public string sortingLayerName;     // The name of the sorting layer the particles should be set to.
    11.         public int OrderInLayer;
    12.        
    13.         void Start ()
    14.         {
    15.             // Set the sorting layer of the particle system.
    16.             renderer.sortingLayerName = sortingLayerName;
    17.             renderer.sortingOrder = OrderInLayer;
    18.  
    19.         }
    20.    
    21.  
    22.    
    23.     // Update is called once per frame
    24.     void Update () {
    25.    
    26.     }
    27. }
    28.  
     
    Last edited: Jun 1, 2014
  25. McSteed

    McSteed

    Joined:
    Apr 26, 2014
    Posts:
    18
    EDIT: OK so here's what I've found. In 2d mode unity automatically brings everything in as a sprite. Easy Hills 2D is fine with that at first creation, and as long as you open it on the same OS, and same version of unity it will continue to work. If you switch OS or upgrade to 4.5 it reveals that the textures have to be set to Texture (rather than Sprite or GUI/sprite) and Repeat (rather than clamp). With the correct import settings it seems to go back and forth between between Mac and PC.



    Hello.

    Help please.

    If I update the texture for my hills it ruins the mapping of the hills. They turn streaky as if they were planar mapped from above. I have to make a new version every time rather than re-saving the existing one.

    A similar issue happened when I upgraded to 4.5 (I have reverted back to 4.3.4). Additionally I just transferred my project to a Mac for the first time and the same thing happened. If I transfer it back to PC after fixing the mapping it ruins it again.

    I've tried re-importing the Easy Hills package and it doesn't fix the problem. The only thing that does is making a new image file.

    As I am trying to develop for multiple platforms this is frustrating. I still am very happy with Easy Hills but this is a big problem for me.



    Thank you,

    EDIT: It also turns off the is Deko.

     
    Last edited: Jun 6, 2014
  26. GouravGoyal13

    GouravGoyal13

    Joined:
    Nov 2, 2013
    Posts:
    7
    hello langem,

    I am using your plugin, but it does not shows tools option up in the menu bar. What do i do

    Regards
    Gourav Goyal
     
  27. GerryR

    GerryR

    Joined:
    Jun 21, 2014
    Posts:
    5
    Does it work with unity 4.5?
     
  28. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    7,051
    Are the vertices in way that span the whole y axis? There are ways i think to create local detail from the bigger vertical polygons, though that would require a different approach in coding i guess
     
  29. McSteed

    McSteed

    Joined:
    Apr 26, 2014
    Posts:
    18
    Any idea why the hills wont hold a Physics 2D material? As soon as you run the game the material vanishes.

    also it would be good if you could have a Physics2D material added at creation time the way the shader is added.
     
  30. langem

    langem

    Joined:
    Mar 18, 2013
    Posts:
    73
    @GouravGoyal13: Simply restart Unity or click on the Toolbar. I think it's a Untiy glitch

    @GerryR: Yes it works in Unity 4.5. Don't forget to check if the textures are set to repeat. 4.5 importing sometimes messes this up.

    @nasos_333: Yes that would require another approach (2D Voxel). There are some nice Assets in the store though.

    @McSteed: Yes that seems to be a bug :( A quick fix would be to add this to "EasyHill2DNode.cs":
    Code (CSharp):
    1. // Line 74
    2. public PhysicsMaterial2D physicsMaterial;
    Also replace at line 155
    Code (CSharp):
    1. if (a != null) {
    2. a.Reset ();
    3. }
    with

    Code (CSharp):
    1. if (a != null) {
    2. physicsMaterial = a.sharedMaterial;
    3. a.Reset ();
    4. a.sharedMaterial = physicsMaterial;
    5. }
    Sorry for the inconvenience...
     
  31. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,565
    Hey, when your tool creates a hill or pipe (im interested in the pipe), does it create a game object for every `knot` in the beziers? So like if there are 4 beziers to a hill section, does that have 4 child gameobjects ... I want to know specifically if the knots can be animated using animation clips (which cannot animate arrays or objects within objects). ... do you store the knots and handles as gameobjects (or at least the knots as gameobjects with 2 handles each, accessible by the anim clip)? If it can I will buy it. If not then not.
     
  32. langem

    langem

    Joined:
    Mar 18, 2013
    Posts:
    73
    Yes, there would be 4 separate gameobjects. Animating the segments is not implemented. Theoretical it would be possible though with some work... The control points are seperate gameobjects as well but I didn't try to animate then yet.
     
  33. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,565
    If they are game objects they are animatable. I guess then the only thing it would need is to re-generate the mesh at runtime. Is that a feature?
     
  34. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,565
    If I don't use the `clean` function to remove the meshes, will it keep them and not regenerate them at runtime?
     
  35. haim96

    haim96

    Joined:
    May 24, 2013
    Posts:
    88
    Hello!

    i just bought this asset, i thought it can create infinite terrain but could find how. am i wrong?
     
  36. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,565
    I don't know that that's an advertised feature, just that you COULD use it to make terrain. I guess you could just create a whole bunch of prefabs of sections of land and then instantiate them in some random order according to which ones fit together?
     
  37. haim96

    haim96

    Joined:
    May 24, 2013
    Posts:
    88
    in that case it doesn't help me..... i'm not sure why i got the impression it is possible with this asset....
    any chance for refund? :rolleyes:
     
  38. McSteed

    McSteed

    Joined:
    Apr 26, 2014
    Posts:
    18
    Update: my game is coming out soon. Thanks for your plugin. It helped a ton!

     
  39. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,565
    Hey a question... as in the image below, I'm basically using 4 pipe beziers to build a circle. The handles for the beziers are exactly axis-aligned/perpendicular at 90 degree angles. Below, the blue vertical line pointing straight down is the handle. However, at the point where two beziers meet, there is a gap toward the outside edge. You can see that the inner `edge collider` in green is at a slight angle away from vertical, which is understandable because at the second point below the center there is some curvature to the circle starting to take effect. It seems then that (if I see your code correctly), you take an angle perpendicular to one of these two vertices (or center along the edge?) and extrapolate it out to produce the outside edge. But this is resulting in a gap, because of the fact that this quad has a slight curve to the inner edge. I'm fully aware I can just tweak the handles slightly to close the gap, which `pinches` the outside edges together, but makes the mid-edges of the circle slightly flatter seeming than they should be. Is there some other way you'd suggest getting this to match up? Or might it be an option you could add or a different calculation for the extrapolation? I will probably just work around it with a slight tweak to the handles but it'd be nice if it would produce a full sweep of a quarter circle without having to fudge it. It's worth noting that this gap appears on both ends of the bezier.

    Thanks
    gap.png
     
  40. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,565
    Hmm. In your code for calculating the mesh, for the pipe, as below, the part where you say `90` or `-90` seems to be slightly incorrect. When I changed it to 89, the gap closed up... almost slightly overly closed.. so I figured this related to the number of segments (I am using 50). If my calculation is correct, because I'm using 50 segments over a 90 degree sweep for the pipe, 90/50=1.8, then 1.8/2=0.9, tells me that each end vertex needs to be adjusted by 0.9 ... e.g. 89.1 and -89.1 ? ... but this is only in the case of this many segments. Changing the segments obviously changes this needed offset. So I think you need to update the asset to calculate this slight difference (the size of half of 1 segment) and subtract it from those two 90's. ??

    if (i < groundVertices.Length - 1) {
    Vector3 bv = (physicsVertices - physicsVertices [i + 1]).normalized;
    bv = Quaternion.AngleAxis (90, Vector3.forward) * bv;
    temp += bv * segmentHeight;

    } else {
    Vector3 bv = (physicsVertices - physicsVertices [i - 1]).normalized;
    bv = Quaternion.AngleAxis (-90, Vector3.forward) * bv;
    temp += bv * segmentHeight;
    }
     
  41. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,565
    I did this to the code, works now... I had to go with *0.52 instead of *0.5 on calculating the gap amount because it still showed visible artefacts of occasional gaps.

    float elementNumberGap = (90.0f/elementNumber)*0.52f;
    for (int i=0; i<groundVertices.Length; i++) {
    Vector3 temp = physicsVertices ;
    if (i < groundVertices.Length - 1) {
    Vector3 bv = (physicsVertices - physicsVertices [i + 1]).normalized;
    bv = Quaternion.AngleAxis (90f-elementNumberGap, Vector3.forward) * bv;
    temp += bv * segmentHeight;

    } else {
    Vector3 bv = (physicsVertices - physicsVertices [i - 1]).normalized;
    bv = Quaternion.AngleAxis (-90f+elementNumberGap, Vector3.forward) * bv;
    temp += bv * segmentHeight;
    }
     
  42. B2F

    B2F

    Joined:
    Jul 10, 2013
    Posts:
    16
    I can't seem to get the deco to work. It just shows up as nothing when I use the grass material that comes with it. Even in the demo scenes it doesn't show up. Any ideas?
     
  43. GalacticGoat

    GalacticGoat

    Joined:
    Oct 1, 2014
    Posts:
    4
    Same problem here. Bump.
     
  44. langem

    langem

    Joined:
    Mar 18, 2013
    Posts:
    73
    Hi, concerning the grass material. If you upgrade to the latest versions you have to check the image import settings (Inspector). Texture Type = Advanced and Wrap Mode = Repeat. Otherwise nothing will show up since the material/shader uses u/v coordinates >1 and <-1. Hope that helps and sorry for the late reply. Buisy times...
     
    GalacticGoat likes this.
  45. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,565
    Hi. A couple of feature ideas that I've found while working with this tool.

    a) Have a `density` option which lets you say, I want my individual triangles to be no more than x units apart, so that the number of sections in a single bezier automatically adjusts to keep that `resolution`. I find e.g. if I'm editing, I start with a prefab or whatever, maybe 50 sections to the bezier, but if I make that particularly bezier somewhat bigger than normal, then it needs more than 50 sections, or if I go smaller, it doesn't need 50. If it could adjust the count automatically as I adjust the curve that would be great.

    b) There is a good need for the snapping.. I like how it connects sections together. What I don't like is that it doesn't line up the handles of the two beziers where they meet, so that you get a perfect seamless curve flow. Instead I have to hand-tweak the handles to make them align correctly and avoid any gaps between geometry. If there could be an auto-align checkbox or something, so that when it snaps it also matches the handle angles, that would also be a big timesaver.

    c) As you probably know, having more triangle segments around sharper bends and fewer segments around flatter areas is a way to optimize the density of geometry so that the curve remains looking smooth but uses less triangles on flatter shapes. Not utterly essential, but it could be a nice feature.

    d) One other thing... the whole thing about erasing all the edges, rebuilding stuff at runtime... it's cool, but I'd like it to be OPTIONAL... I'm finding it frustrating, because unless I remember to remove all the geometry before building, it builds, and then the windows app does NOT rebuild any of the geometry at runtime (or it doesn't show for some reason). I'd like to either disable this feature with a checkbox which `keeps` the geometry (because I may also have done something TO it after the fact, which then gets wiped/replaced), or a way to get the geometry to actually rebuild when the app plays (supposed to, right? does not for me).


    Generally speaking I really like this tool. I'm basing a game around it.
     
    Last edited: Feb 25, 2015
  46. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,565
    Just FYI for others, to enable the options on edgecolliders to be KEPT when the segments are cleaned/removed/restored, e.g. `used by effector` etc... I made a couple of changes to code. In the node code and in the manager code, where it says like

    Object.DestroyImmediate (n2.gameObject.GetComponent<EdgeCollider2D> ());

    I changed it to

    n2.gameObject.GetComponent<EdgeCollider2D>().points=new Vector2[2];

    There are a couple of entries like this, plus another in the node's awake function where you see

    if (a != null)
    a.Reset ();

    I changed it to

    if (a != null){
    a.points = new Vector2[2]; //paul, to prevent loss of settings on edge collider
    //a.Reset ();
    }

    ie basically set the points array to empty instead of wiping out the collider. If you're working with Unity5 effectors you don't want to lose which object's colliders are used with effectors, but these changes allow you to still keep the mesh data to a minimum in the build while still having the options you chose. This also lets you keep any physics material you chose on the collider.
     
  47. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,565
    Hey, just a little feedback. In my project I'm using quite a modified version of EasyHills2D and using the pipes to create curved surfaces... I also modified it to allow me to animate certain pipes by continually regenerating the mesh/colliders. Its working fine.... but what I found is that in the CalculaveUVs() function in the node script, the way you've programmed it, reading things like the vertices array length, when profiled over numerous mesh rebuilds, really proves to be a huge performance hog. Because the script gets the vertices array length, each time it does it the whole vertices array has to be memory-allocated into a temporary array (it seems) to then get the length of it. Also reading any existing vertices directly from that array without using an offline copy of the array, also has a similar penalty. I modified it for myself to a) preallocate array space that I keep re-using unless its length changes, b) store the vertices that I previously uploaded to the vertices on the mesh in that array so that I can get its length and content quickly, c) change the code in the UV generator to refer to the array I kept, instead of the vertices array on the mesh. When I did this, my performance for this one function went from ~14 milliseconds to ~0.3 milliseconds. This was by far the biggest hog of performance in the entire project. In my project i update 4 nodes every frame, comprising 25-50 triangles each. So you might want to consider keeping a stored copy of the vertex data and then re-using it to create the UV coordinates. I know your system doesn't have animation/constant mesh generation built in, and maybe its not noticeable if it's just called once per node, but it really adds up fast. For me personally I also made one-time-allocated arrays that I keep and re-use (unless length changes), rather than the places where you have vector2 and vector3 arrays being allocated on the fly, as this cuts down a lot on garbage collector activity as well. Just some thoughts.
     
  48. TagliatL

    TagliatL

    Joined:
    Feb 5, 2013
    Posts:
    1
    Hi ! I got some problems using your plugin.
    I'm doing a plateformer with a ball, and I want to make some curves to roll on it. I'm using sprites and 2D colliders.
    But I go through the road I created with your plugin, I don't know why. Is there any collider to add on the segment ?

    EDIT: I actually found out that you're using edge collider but when I use it, it doesn't fit the curve, even if I edit it.
     
    Last edited: Mar 17, 2015
  49. GalacticGoat

    GalacticGoat

    Joined:
    Oct 1, 2014
    Posts:
    4
    Upgraded to Unity 5 and the only problem with my project is that the hills are invisible. Any suggestions?

    Edit: they are visible on PC but not android
     
    Last edited: Mar 22, 2015
  50. kozle

    kozle

    Joined:
    Aug 6, 2015
    Posts:
    46
    Hello.

    First of all... thank you for this asset. It is exactly what I need.

    ...but... I use Unity 5....
    What is the process that creates Edge Collider?

    When I create segment and edit it, it doesnt have Edge Collider. If I add it manualy, it only has two points. First and the last. How can I update Edge Collider, so it refreshes its list of points?
    I managed to do it once by clicking and unclicking "Use Ground Collider" box.... but it doesnt work anymore...

    thank you for your help