Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

【Ground Fitter (free)】- Fit your dynamic objects to ground

Discussion in 'Assets and Asset Store' started by FimpossibleGames, Jul 20, 2018.

  1. FimpossibleGames

    FimpossibleGames

    Joined:
    Jun 27, 2018
    Posts:
    160
    Ground Fitter is component which is dynamically fitting object to ground.

    You can choose if you want fit object in X and Z rotation axis (good for spiders) or only X (human/quadropeds etc.)

    Thanks to generated additional transform you have clear control over Y axis rotation and can use transform.forward to move in desired direction.

    > Link To Asset Store <

     
    jonfinlay, eaque, DrOcto and 2 others like this.
  2. Firlefanz73

    Firlefanz73

    Joined:
    Apr 2, 2015
    Posts:
    1,102
    Hello,

    first of all: thanks a lot for this free asset, which sounds extremly interesting!

    I am trying this on my 4-foot animals.

    First test subject is my cow.

    I tried with the Standard values, and see no Change. My landscape has 45° slopes or plain Ground, on the Slops I expect the "front feet" to be a bit more upwards or downwards now? But it Looks like before, no Change.

    upload_2018-7-28_9-49-34.png

    So I set values to be more fast (Speed), removed the "match side Rotation" and set the "raycast height Offset" to the character controller height.

    Still Nothing happens. The Colliders are Standard layers, no Change here.

    Any idea what am I missing?

    Thanks!
     
    DrOcto likes this.
  3. Firlefanz73

    Firlefanz73

    Joined:
    Apr 2, 2015
    Posts:
    1,102
    PS: Height Offset on 0.15 also see no change.
     
  4. Firlefanz73

    Firlefanz73

    Joined:
    Apr 2, 2015
    Posts:
    1,102
    PPS: It has something to do with the Ground layer I guess. I have no Special Ground layer.

    // If cast catch ground
    if (LastRaycast.transform)

    here never Returns true. I will examine my layers. I guess in the readme a short hint and a sample would be helpful?

    Anbd the Groundlayer mask could be a good idea to be in the inpector like the other public variables?

    Thanks.
     
  5. Firlefanz73

    Firlefanz73

    Joined:
    Apr 2, 2015
    Posts:
    1,102
    Hello,

    me again, got it working now (I just completly removed all groundlayermask stuff from the code).

    Some improvement ideas maybe:

    Maybe a public bool use LayerMask? If not just ignore all of it. Works good for me.

    One Problem: if a cow goes down 45° sometimes it jumps between I guess 30° and 60° Degrees multiple times a secone. That's a Problem, I try with slower Speed again.

    One Suggestion: If my cow runs down or up 45° it sometimes looks strange. And in real life, it could not do that, but in my Chunk-Landscape (like minecraft but with 45° slopes instead of 1 meter high single blocks in the landscape) it Needs to be this way. Maybe a maximum Rotation could help? Like it is running 45° upwards, but only rotates 30° upwards (and same for downwards) so it is a bit wrong, but still Looks better on the cow?

    PS: With Speed 6 again sometimes it works climing 45°, sometimes it jumps between 30° and 60°, this way it is unusable! Maybe if you like to improve it, just do a little demo scene with some plain areas and some 45° slopes between one and three meters long. And very small slope changes or small obstacles should be ignored, too, maybe with a public parameter like "Ignore changes smaller than X"...

    Just some suggestions / ideas.

    Thanks a lot! I will test it on other animals now :)
    I also have a big crokodile! Which should be the worst Scenario :p But it would be really good if it worked for Standard animals like cows, sheep, wolfs etc.
     
    Last edited: Jul 28, 2018
  6. FimpossibleGames

    FimpossibleGames

    Joined:
    Jun 27, 2018
    Posts:
    160
    Hi! Thanks, I wrote line about layer mask in readme but I assume very few people will read this :D
    I currently made layer masks in public value, this is the way I should done it at first place, but I must wait for update approval.

    I have in plans enchance this package with more features, but feel free to suggest, I will put it in my task list for package :)
     
    Firlefanz73 likes this.
  7. Firlefanz73

    Firlefanz73

    Joined:
    Apr 2, 2015
    Posts:
    1,102
    Thanks a lot!

    If you add something like a minimum angle or height to be ignored, or a maximum rotation angle, that would be great!

    I would like to beta-test, I have around 30 different animals :)
    Feel free to send me the updated script if you like Feedback! Thanks again.
     
  8. Firlefanz73

    Firlefanz73

    Joined:
    Apr 2, 2015
    Posts:
    1,102
    Hello,

    the two animals in the sample are using rays. Is there already a possibility to detect if they are Standing a front of the wall? Like no Rotation needed, but cannot move Forward anymore because of a wall and not a slope?

    I am having problems to detect a wall, which is not only a slope but really a wall...

    Thanks a lot!
     
  9. FimpossibleGames

    FimpossibleGames

    Joined:
    Jun 27, 2018
    Posts:
    160
    Hey, sorry for late reply but I was on holidays ;)
    You can use raycast or collider ;)
    I planning add in some update controller for movement like in this video (just translation, no animation)
     
  10. FimpossibleGames

    FimpossibleGames

    Joined:
    Jun 27, 2018
    Posts:
    160
    Version 1.1 released!
    - Fully controllable rotation limits with some new extra options
    - Demo scene with third person movement using ground fitter and toggle to use physics (experimental)



    > Link To Asset Store <
     
    Firlefanz73 likes this.
  11. Firlefanz73

    Firlefanz73

    Joined:
    Apr 2, 2015
    Posts:
    1,102
    That Looks extremly interesting! I will try that :) Thanks
     
  12. Firlefanz73

    Firlefanz73

    Joined:
    Apr 2, 2015
    Posts:
    1,102
    Hello,

    I just downloaded your lateast Version and I am playing around with values for my cows. To add other animals later if it works…

    The Ground height seems to be okay and if they walk Downhill it looks good.

    But they never walk uphill! I also tried with look ahead 0.5 but still nothing. They still play the Walking Animation but do not move anymore, if there is an uphill before them, in my case These are between 30 and 60 Degrees, think of a much simpler landscape....

    How do I get them to walk uphill, too? Is the value for raycast height Offset okay compared to the character Controller y Offset? Thanks a lot :)

    upload_2018-10-4_23-49-51.png
     
  13. FimpossibleGames

    FimpossibleGames

    Joined:
    Jun 27, 2018
    Posts:
    160
    Enter on variables (not in playmode) to see tooltip for variables, maybe they will guide you.
    You can try use raycast height offset, then raycast wil be casted from little higher point.
    Also when you have long animals like cows, consider using look head raycast and ahead blend - it will make another cast a little at front from origin position of your transform and make like average of this two rotations.

    I don't know how this stuff will work with character component - also character component.Move() method is kinda expensive when you use more than 30 of them.
    You can send me project with your terrain and one animal then I would check what's going on, hard to tell right now.
     
  14. Firlefanz73

    Firlefanz73

    Joined:
    Apr 2, 2015
    Posts:
    1,102
    The source code of my Project is around 12 gb :)
    But Maybe I could make a Little sample with just the cows (or a replacement for them) with the character Controller or my landscape which has 45° slopes could be causing this problem...

    One question: Could the scripts in this asset be used to detect a hole in the landscape to stop and turn around or a wall / obstacle to stop and turn around?

    I still have huge Problems with my animal "wander" ai and monster follow ai and I bought "ICEcreature" a year ago but I never got it Working and now it is officially not supported anymore (and before there was no real Support).

    Thanks :)
     
    eaque likes this.
  15. FimpossibleGames

    FimpossibleGames

    Joined:
    Jun 27, 2018
    Posts:
    160
    I would need only animal mesh and terrain ;)
    Scripts in this asset are only for fitting purpose, you can check Nav Meshes for that stuff or do it other way, probaby there are tutorials for such AI on youtube ;)
     
  16. Firlefanz73

    Firlefanz73

    Joined:
    Apr 2, 2015
    Posts:
    1,102
    Yes there are plenty navmesh tutorials, but not much without navmesh.
    I have a complete procedural randomized landscape without waypoints etc and I want my animals just to wander around and flee if Player attacks them, and Monsters to follow Player on sight.

    Already works pretty well with my own script until there is a hole or a obstacle / wall :)

    I you add that stuff and make a working asset for 10-20 bucks I will be the 1st one who is buying :D
     
  17. FimpossibleGames

    FimpossibleGames

    Joined:
    Jun 27, 2018
    Posts:
    160
    That's nice idea :) I could make shepherd game example, but first I must make some other things done, which can take few weeks.
     
  18. Firlefanz73

    Firlefanz73

    Joined:
    Apr 2, 2015
    Posts:
    1,102
    Sounds great. My animals and Monsters drive me nuts, and I don't want to Add waypoints or navmeshes and this would be diffilcult in my case :)

    The groundfitter would be a great Option! And I guess for others navmeshes could also be great Option, but for me it is just wander, flee from Other object, follow Other object and avoid holes and obstacles and straight walls...

    I will make a sample Scene with my landscape.
    I guess it would be okay to include some animals which do not belong to me, I bought them from here?
    https://assetstore.unity.com/packages/3d/characters/animals/animals-full-pack-5032
    Or I can Add something else that is not on the store or Maybe from your sample...

    I am open for beta-testing lol :)
     
  19. FimpossibleGames

    FimpossibleGames

    Joined:
    Jun 27, 2018
    Posts:
    160
    Oh if you using models from protofactor you don't need to add them, I know how they models works with axes, that was the reason why I wanted them for debugging.
    So you can send me only landscape with your gameobject with groundfitter, empty inside (without model).
     
  20. Firlefanz73

    Firlefanz73

    Joined:
    Apr 2, 2015
    Posts:
    1,102
  21. Firlefanz73

    Firlefanz73

    Joined:
    Apr 2, 2015
    Posts:
    1,102
    Hello,

    It seems to work very well with the new setting for "Change Position" for my case with the character controller.
    Thanks for the update!
     
  22. FimpossibleGames

    FimpossibleGames

    Joined:
    Jun 27, 2018
    Posts:
    160
    Wow, I did not expect it will help but glad to hear it :)
    Also as I know you making game with lots of animals, then you should check my new asset released few hours ago ;)
    > Spine Animator on the asset store <
    And last week trailer when I use Ground Fitter, Spine Animator and others to boost animations quality:
     
    Last edited: Oct 15, 2018
    jonfinlay likes this.
  23. Firlefanz73

    Firlefanz73

    Joined:
    Apr 2, 2015
    Posts:
    1,102
    Looks very interesting! Is this working with protofactor's animals?
    The link does not work for me, but I found it by searching...
     
  24. FimpossibleGames

    FimpossibleGames

    Joined:
    Jun 27, 2018
    Posts:
    160
    Ouh I accidently pasted preview link.
    I tried to make this component as universal as possible and also Protofactor's monsters models was in my testing library so I'm sure it should work without a problem ;)
     
  25. Firlefanz73

    Firlefanz73

    Joined:
    Apr 2, 2015
    Posts:
    1,102
    Hello,

    I have a problem left with ground fitter:

    upload_2018-10-16_21-15-0.png

    It rotates my animals around Y sometimes, so they run away instead of attacking the Player etc.
    I spent an hour Looking why they do, when I remove Ground fitter everything is fine, when I add it like this, they rotate a lot and very fast between the correct direction and some other Maybe opposite direction…

    How can I tell Ground fitter it should never rotate around Y?

    Thanks :)
     

    Attached Files:

  26. FimpossibleGames

    FimpossibleGames

    Joined:
    Jun 27, 2018
    Posts:
    160
    Ouh, variable "Rotation Y Axis" is meant to be used for objects movement direction (rotation is contantly overrided from component), thanks to this variable you always go in correct direction, no matter if object will walk on vertical wall or ceiling.
    When object is moving over ground and rotating there all axes need to be used, you can't ignore it.

    You can modify your script and use ground fitter "Rotation Y Axis" for movement direction or put your animal with just ground fitter inside other game object which will have rest of components you need.
     
  27. Firlefanz73

    Firlefanz73

    Joined:
    Apr 2, 2015
    Posts:
    1,102
    Like this? In my script for movement:

    groundFitter = GetComponent<FIMSpace.GroundFitter.FGroundFitter>();



    if (groundFitter != null)
    {
    groundFitter.RotationYAxis = transform.rotation.y;
    }

    Does not seem to help, still rotating a lot around Y...
     
  28. FimpossibleGames

    FimpossibleGames

    Joined:
    Jun 27, 2018
    Posts:
    160
    No, to understand add your model on some big slope, rotate it to ground (using x and z axis) and change Y axis value in inspector, you will see when you do it by hand, model will rotate in weird way, variable inside ground fitter makes rotation works always the same no matter how object is rotated on uneven terrain.
    You can check how works usage of this variable in code inside demo scripts.
     
  29. Firlefanz73

    Firlefanz73

    Joined:
    Apr 2, 2015
    Posts:
    1,102
    Thanks for the hints!

    For now I removed the Ground fitter from my Monsters and animals, there is too much Impact with my exisiting Script using a character Controller. But I want to get rid of it anyway, I want to have a better and simpler Script and without using a character Controller...

    I find your ground fitter and your spine animator both great, a script with a target and a follow or flee or wander status, using the raycasts for obstacle and hole avoidance would be great, it should include or work together with these two existing assets, that would be totally great :)
     
    eaque likes this.
  30. eaque

    eaque

    Joined:
    Aug 20, 2014
    Posts:
    592
    HI,
    I tried this asset (few minutes) thanks for providing it free.

    -I used it with the third person template by Unity to make the character rotate only a bit on slopes and it seems not to function....What am i missing? Is it compatible?

    -Is there a way to limit forward on high slopes with your components?

    -Is it possible to simplify Ground fitter to only return the value of slopes thru the ray cast and use those values inside some other scripts?
    thanks
     
  31. FimpossibleGames

    FimpossibleGames

    Joined:
    Jun 27, 2018
    Posts:
    160
    Hi,
    I wasn't trying to use it with third person controller, probably there can be some conflicts.
    Remember about setting right collision layers in "Ground Layer Mask" variable.
    You can try untoggling first variable "Change Position" but then you have to change variable "RotationYAxis" from code which is angle in degrees for forward direction.
    Also you can try putting object which have to be rotated inside child game object, but now I'm not sure if "RotationYAxis" then have to be changed anyway.

    "-Is there a way to limit forward on high slopes with your components? "
    You mean going up high slopes?
    You can check GroundFitter_Demo scene and inside PR_GroundFitter_Feetle enable "Use Physics" in GroundFitter_Movement component, it will limit going up slopes but it's defined by physic itself, slopes are limited by movement speed, collider and object's rotation, then probably rigidbody mass too. To use this physic feature you need to have collider and rigidbody attached to your game object.

    -Is it possible to simplify Ground fitter to only return the value of slopes thru the ray cast and use those values inside some other scripts?
    You can try changing this lines:

    Code (CSharp):
    1.             if (TotalSmoother == 0f)
    2.                 transform.rotation = targetRotation;
    3.             else
    4.                 transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation,
    5. delta * Mathf.Lerp(50f, 1f, TotalSmoother));
    6.  
    7.             LastRotation = transform.rotation;
    to this

    Code (CSharp):
    1. LastRotation = targetRotation;
    Then "LastRotation" variable should have desired rotation, but you should remember about "RotationYAxis" variable, and you should have "ChangePosition" setted to false.

    I am working on upgrading ground fitter to V2.0 (it will not be free anymore, but anyone who have it already will not have to pay) and it will provide much more examples, will be more polished and designed to replace Unity's build in movement controller.
     
    eaque and Firlefanz73 like this.
  32. eaque

    eaque

    Joined:
    Aug 20, 2014
    Posts:
    592
    Many thanks for your very precise answer!

    Actually ground fitter could be an amazing Third Person Controller compared with some on the store that are very expensive. handling multiple speeds jump and slope limits would be perfect for many people if they can add their own moves later. You could even change the name after the update;)

    Combined with some of your other modules i think it could be a great solution, you should promote it this way!!


    I don't know what you wanna do with it but i will follow so as for your other assets! i left a message in Look animator to know if i can use it with TPcontroller!;)

    Cheers
     
    FimpossibleGames and Firlefanz73 like this.
  33. Litwin

    Litwin

    Joined:
    Aug 15, 2013
    Posts:
    60
    Yo, Ground Fitter is optimized for use on mobiles?
     
  34. FimpossibleGames

    FimpossibleGames

    Joined:
    Jun 27, 2018
    Posts:
    160
    Hey, this code don't need to be optimized directly for mobiles, it's just optimal.
    How much? You can test it by using "Duplicator" game object in "Patrolling" example scene, but remember to check only code performance, rendering so many meshes can take more fps.
     
  35. Firlefanz73

    Firlefanz73

    Joined:
    Apr 2, 2015
    Posts:
    1,102
    Exactly what I think. +1 vote for this :) I'll buy it!
     
    eaque likes this.
  36. eaque

    eaque

    Joined:
    Aug 20, 2014
    Posts:
    592
    So we think the same thing i guess!! :)

    This has a huge potential added with look animator and just a few modules...

    We would need:
    -some speed states and the possibility to create some states. (Walk, run, roll, crouch, so on) Only rigging an animation to a speed
    -Simple push forward option for rolling or strafing or i don't know...
    -A Freeze state, like no input.
    -Stop moving forward On Slope LImit :) only y rotation alowed
    -Jump static and in movement
    -

    -And the BEst of The Best to me it could be a fantastic hack to Get Climbing any surface for humanoid!!:cool::cool: Like in Zelda BOTW you could rotate the raycast zone to move vertical and check angle on Surface....
    Am i dreaming to much?:oops:
    BTW with all the data you have in GroundFitter you could do some IK for foosteps??

    I was thinking that a lot could be accomplished to rework existing animations, even using look animator as false IK like carry object with each arm looking at points....:):)(oops other thread :p)
    ...
    Now the author will raise the price :p
     
    Firlefanz73 and FimpossibleGames like this.
  37. Firlefanz73

    Firlefanz73

    Joined:
    Apr 2, 2015
    Posts:
    1,102
    For me personally climbing would be less interesting but could be nice too.

    The Other Features would be great :)

    And I already added the request for Setting a target (GameObject could be Player, NPC, Prey) and a Status to follow / hunt or flee from. I would use it for all non Player characters like monsters and animals :)

    I could need this for both my current game and my next game.
     
    eaque likes this.
  38. eaque

    eaque

    Joined:
    Aug 20, 2014
    Posts:
    592
    perfect!! :)
     
  39. FimpossibleGames

    FimpossibleGames

    Joined:
    Jun 27, 2018
    Posts:
    160
    Thank you guys for suggestions, really nice ones, I will put them in my list for V2.0 :)
    Also walking on straight up wall is possible now with ground fitter, but it's not polished yet, model have to rotate in some way toward straight up wall and then it stitch to it, check this moment and watch tall box on the left.
     
  40. eaque

    eaque

    Joined:
    Aug 20, 2014
    Posts:
    592
    we thank you for listening! :)
     
  41. giraffe1

    giraffe1

    Joined:
    Nov 1, 2014
    Posts:
    185
    Hi,

    I recently came across your awesome asset. Can I use your asset to make my humanoid NPC stick to the ground?

    I am trying to recreate the Unity character controller behavior. I am trying to align my NPC's transform.position.y value to match the ground.

    I played around with your asset but I think I must have the wrong settings because it seems to take control over my AI's movement and stop it from doing it's own thing.

    Any idea's? I can make a video of the problem if needed.

    Thanks
     
  42. FimpossibleGames

    FimpossibleGames

    Joined:
    Jun 27, 2018
    Posts:
    160
    Hey, if you mean gluing npc to the ground and rotating it to fit ground you need to use "RotationYAxis" variable through code, if you rotating npc's using something like "Quaternion.Euler(0f, rotation, 0f);" then replace it with "groundFitter.RotationYAxis = rotation;" then to move your npcs you can check demo patrolling component, it is changing object's position to raycast point then moving:

    "if (fitter.LastRaycast.transform) transform.position = fitter.LastRaycast.point;
    transform.position += transform.forward * speed * Time.deltaTime;"

    Will it work with your npc's code? ;)
     
    giraffe1 likes this.
  43. jonfinlay

    jonfinlay

    Joined:
    Aug 25, 2015
    Posts:
    535
    Just found this on the store, absolutely can’t wait to try this out, exactly what I’d been looking for. Never been happy with the animal controllers I have as they sometimes slide or do unpredictable movements. A big thanks for putting this out free :) I’ve got a lot of animals from Junninchi Suko, so will let you know how they work with it. Thanks again.
     
    FimpossibleGames likes this.
  44. PlayingKarrde

    PlayingKarrde

    Joined:
    Aug 19, 2013
    Posts:
    28
    How can I use one off root motion animations with this? I'm using root motion to drive the forward which works fine but I can't seem to figure out how to keep root motion in other animations. I'm using the GroundFitter_Movement as a base as in the tutorial you posted on youtube.

    Right now the animation will play in place without any position or rotational changes and I can't figure out how to fix it.
     
  45. FimpossibleGames

    FimpossibleGames

    Joined:
    Jun 27, 2018
    Posts:
    160
    I've sent to you package with update to use rotation of root motion, if it will work I will update package on the store.
     
    eaque and PlayingKarrde like this.
  46. NerdIt-

    NerdIt-

    Joined:
    Oct 19, 2018
    Posts:
    15
    @FimpossibleGames
    Hi. I just installed Ground Fitter and I got a few questions. I did read through the Read Me file but I couldn't find any answers really. My first questions is, is there any way to just turn the Rotation Y Axis off. I have another script that is supposed to be controlling the y axis. If not how do you change it via script. I tried the basic Get Component, but just go an error.
     
    Last edited: Sep 17, 2019
  47. FimpossibleGames

    FimpossibleGames

    Joined:
    Jun 27, 2018
    Posts:
    160
    The thing is that fitting is not using only x and z axis to rotate object to the ground, it needs all 3 axes to be involved to be able to glue object on ground. YAxis variable of ground fitter behaves like top down degrees direction from outside, but inside it's doing few important calculations to make object rotation be able face YAxis rotation.

    Solution for you is replacing code which is rotating y axis to be like groundFitter.RotationYAxis = newYRotation;
    Where groundFitter is reference to component of your character, look again on your code for GetComponent, it works without any problem, also you can check demo scripts for example for patrolling ;)
     
  48. NerdIt-

    NerdIt-

    Joined:
    Oct 19, 2018
    Posts:
    15
    I still can't get it to work. I've tried the namespaces groundFitter, FGroundFitter and numerous others. I looked at some of the example creatures and I still couldn't find something that worked.

    Code (CSharp):
    1. FGroundFitter fitter;
    what would I replace the FGroundFitter part with?
     
  49. FimpossibleGames

    FimpossibleGames

    Joined:
    Jun 27, 2018
    Posts:
    160
    This should help

    Code (CSharp):
    1. using FIMSpace.GroundFitter; // Use this
    2. using UnityEngine;
    3.  
    4. public class GroundFitterAccess : MonoBehaviour
    5. {
    6.     // FIMSpace.GroundFitter.FGroundFitter
    7.     // or add 'using FIMSpace.GroundFitter;'
    8.     // You can also write FGroundFitter and then press left ctrl+.(dot)
    9.     // then visual studio will ask to add 'using' or 'FIMSpace.GroundFitter.FGroundFitter' (but only when you don't have added 'using')
    10.     FGroundFitter fitter;
    11.  
    12.     void Start ()
    13.     {
    14.         fitter = GetComponent<FGroundFitter>();
    15.     }
    16.  
    17.     void Update ()
    18.     {
    19.         fitter.RotationYAxis = newRotationInYAxis;
    20.     }
    21. }
     
  50. NerdIt-

    NerdIt-

    Joined:
    Oct 19, 2018
    Posts:
    15
    @FimpossibleGames Not sure if this a problem with your code or just unity in general but do you know why this is happening?
    Code (CSharp):
    1. fitter.RotationYAxis = lookCenter.rotation.y;
    So I am just setting the RotationYAxis to copy another object's y rotation axis, but once I start the scene, the RotationY Axis displays a decimal, not at all the correct number. I have attached some images below as visual aid.
     

    Attached Files: