Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Malbers Animals-Creatures

Discussion in 'Assets and Asset Store' started by Malbers, Nov 12, 2016.

  1. HeyBishop

    HeyBishop

    Joined:
    Jun 22, 2017
    Posts:
    238
    I'm still new to coding. As a learning exercise, I'm trying to figure out how to make the simplest walk for these creatures, by using the inspector as an input device. Here's what I've attempted - but I get an error message (mentioned after the code).

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using MalbersAnimations;
    5.  
    6. public class MyBasicAnimalMovement : MonoBehaviour {
    7.  
    8.     float walkForward = 1f;
    9.     float walkRight = 0f;
    10.     bool doWalk = false; // to toggle moving or not moving
    11.     [HideInInspector]Vector3 movementDirection = Vector3.zero;
    12.  
    13.     void Update () {
    14.         movementDirection = new Vector3 (walkRight, 0, walkForward);
    15.         if (doWalk)
    16.             AnimalMovement();
    17.     }
    18.  
    19.     void AnimalMovement()
    20.     {
    21.         Animal.Move(movementDirection);
    22.     }
    23. }
    After Unity attempts to compile this code, I get the following error:
    Assets/MyBasicAnimalMovement.cs(26,10): error CS0120: An object reference is required to access non-static member `MalbersAnimations.Animal.Move(UnityEngine.Vector3, bool)'

    What am I missing?
     
  2. Malbers

    Malbers

    Joined:
    Aug 7, 2015
    Posts:
    2,558
    The problem is that you are accessing the Animal Class it self... not the reference for the script attached to an animal...
    you need to use GetComponent...
     
  3. Malbers

    Malbers

    Joined:
    Aug 7, 2015
    Posts:
    2,558
    Realistic is on pending Review :) Unity-Social-FaceR2.png
     
    Rowlan, Hitch42 and SirTwistedStorm like this.
  4. HeyBishop

    HeyBishop

    Joined:
    Jun 22, 2017
    Posts:
    238
    That's it! Thank you for pointing that out to me.

    Here's the code I ended up making, which was very educational for me.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using MalbersAnimations;
    5.  
    6. public class MyBasicAnimalMovement : MonoBehaviour {
    7.  
    8.     [Range(-1,1)]public float walkForward = 1f;
    9.     [Range(-1,1)]public float walkRight = 0f;
    10.     public bool doWalk = false;
    11.     private Vector3 movementDirection = Vector3.zero;
    12.     public Animal animal;
    13.  
    14.     void Start () {
    15.         animal = GetComponent<Animal> ();
    16.     }
    17.  
    18.     void Update () {
    19.         movementDirection = new Vector3 (walkRight, 0, walkForward);
    20.         if (doWalk)
    21.             AnimalMovement();
    22.     }
    23.  
    24.     void AnimalMovement()
    25.     {
    26.         animal.Move (movementDirection, false);
    27.     }
    28. }
    At first, the deer would only move "north", regardless of which direction the deer was facing, when movementDirection = 0,0,1. I eventually discovered the need to add the false bool to .Move(Vector3, bool), to change it from world space to the deer's orientation.

    @Malbers, I'd like to suggest you add the requirement of the bool to your documentation.
     
    Malbers likes this.
  5. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,199
    It's happening, finally! :D

    In case you pick another one up for realism, may I suggest to do the deer next? It would be ideal to toy around with all kinds of landscapes. You have slow movement with them, slow proud movement with the antlers high, horse-like fast running movement and the little one is totally cute :)
     
  6. Malbers

    Malbers

    Joined:
    Aug 7, 2015
    Posts:
    2,558
    Thanks :) I will update the documentation
     
  7. Malbers

    Malbers

    Joined:
    Aug 7, 2015
    Posts:
    2,558
    the next one for realism is the wolf... and next the deer :)
    the wolf is the most popular among all the animals :) so he gets to go realistic first :D :D
     
    Rowlan likes this.
  8. HeyBishop

    HeyBishop

    Joined:
    Jun 22, 2017
    Posts:
    238
    So, I've got my animal walking in a direction I control with the code I shared in my post above. Since then, I have placed an Eat Action Zone in my scene with Automatic turned on, and have the animal through it. It successfully triggers the food to disappear as if it eaten. But, the animal doesn't automatically stop walking and play the eat animation. If I manual switch my DoWalk bool to false while the animal is in the Eat Zone, it will stop and play the animation of eating like I want it to.

    I can't figure out how to automatically stop the animal from walking when it enters an action zone.

    Any ideas on how I could do that?

    Many thanks!

    EDIT: Hang on, it seems like sometimes the animal stops to eat, and sometimes it doesn't. It seems totally random when it works.

    2nd EDIT: I thought it might help to record a video that better explains my woes:
     
    Last edited: Apr 28, 2018
  9. Malbers

    Malbers

    Joined:
    Aug 7, 2015
    Posts:
    2,558
    Thanks for reporting this I'm fixing it now

    Edit:
    Do you have the latest version of the Deer? the last update I made?

    I'm testing it out and is working every time
     
    Last edited: Apr 29, 2018
  10. HeyBishop

    HeyBishop

    Joined:
    Jun 22, 2017
    Posts:
    238
    It wasn't the latest version!
    I updated all of animals that were in my project, and it seems to work every time time. Thank you so much!!!
     
    Malbers likes this.
  11. Malbers

    Malbers

    Joined:
    Aug 7, 2015
    Posts:
    2,558
  12. luckytwitch

    luckytwitch

    Joined:
    May 5, 2018
    Posts:
    1
    Hello Malbers!
    I've been a huge fan of your work for a while and when you released the rabbits I was overjoyed and immediately wanted to try out the demo. However, the link doesn't appear to be working. Could you please fix this? Thank you :D
    (Here is the current link that needs fixing http://bit.ly/PARabbitWGL)
    I'm pretty sure the demo is done already because one person reviewing the product talked about it, but if it's not then that's perfectly fine :) I understand that these things take a lot of hard work.
    PS. I just joined because I wanted to get more involved in your work, so I might just not know what I'm doing :p
     
    Malbers likes this.
  13. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,199
    How is it with the upgrade price:

    upgrade.png

    It's kinda weird that the rabbit is on sale and with the upgrad price i still pay full price because i already bought the asset for 15,-.
     
    Malbers likes this.
  14. Malbers

    Malbers

    Joined:
    Aug 7, 2015
    Posts:
    2,558
    Thanks so much for your support! and for reporting this !! I forgot to make the demo.... the link is already working !!
     
  15. Malbers

    Malbers

    Joined:
    Aug 7, 2015
    Posts:
    2,558
    Okey that is suuuuper weird! on the image it says is 43%off but the upgrade price is 20...

    but yeah... the upgrade from Poly art Rabbit $14.30 to Realistic $(35) is 35-15 ($20)...


    Thanks so much Rowlan for your support... I will always be forever grateful for sticking with me :)
     
    Rowlan likes this.
  16. Malbers

    Malbers

    Joined:
    Aug 7, 2015
    Posts:
    2,558
    Just a clarification..


    Realistic animals are really hard to make ... at least for me... and since the competition with the quality similar to mine is selling his animals on $140 dollars, each animals, with less features.. I believe is a fair price what I'm asking for...
    since also the Realistic Rabbit includes the Poly art version.... with all the features..

    Any way Happy Hopping to all !!
     
    Team21Dev, Akshara and Rowlan like this.
  17. Kaen_SG

    Kaen_SG

    Joined:
    Apr 7, 2017
    Posts:
    206
    I love your Work Malber and I'd really love to support you further... I even bought your Horned monster and I love it (I hope you make more Monsters!) but $35 for a rabbit is a bit too heavy on my wallet. :oops:
     
  18. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,199
    Very awesome @Malbers, I like it :) Had to try them in the scene I posted yesterday

    rabbit 1.jpg
    rabbit 2.jpg
    rabbit 3.jpg
    rabbit 4.jpg
    rabbit mushroom.jpg
    However, still pics don't do it justice, the animations are AAA. Great job!
     
    Last edited: May 7, 2018
    Team21Dev and Malbers like this.
  19. Malbers

    Malbers

    Joined:
    Aug 7, 2015
    Posts:
    2,558
    Really Amazing!!!!!!! ...

    Wait until you guys see the wolf.... Im sooo happy with the realistic wolf sculpt... but is still early to show him :p.
    meanhile more rabbit love!
     
    Team21Dev and Rowlan like this.
  20. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,199
    One of the coolest features when I checked out the demo was climbing in and out of a hole on the ground :D
     
    Malbers likes this.
  21. HeyBishop

    HeyBishop

    Joined:
    Jun 22, 2017
    Posts:
    238
    Is the only way to make your animal walk by calling animal.Move() every frame?

    I want to make my animal walk for X seconds. But, creating a timer in Update() seems cumbersome. Is there another way that I haven't thought of? Like a coroutine? (I've just discovered coroutines! Super new to this way of thinking)

    The following script works, but it seems cumbersome.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using MalbersAnimations;
    5.  
    6. public class SetDurationWalk : MonoBehaviour {
    7.  
    8.     public Animal animal;
    9.     public float walkDuration = 10f;
    10.     public Vector3 movementDirection;
    11.     private float timer = 0f;
    12.  
    13.     void Start () {
    14.         animal = GetComponent<Animal> ();
    15.     }
    16.      
    17.     void Update () {
    18.         timer = timer + Time.deltaTime;
    19.         if (timer <= walkDuration)
    20.             animal.Move (movementDirection, false);
    21.     }
    22. }
     
  22. Malbers

    Malbers

    Joined:
    Aug 7, 2015
    Posts:
    2,558
    You can call it once :) and the animal will go always to that direction until you need to change it :)
     
  23. HeyBishop

    HeyBishop

    Joined:
    Jun 22, 2017
    Posts:
    238
    In my continuation of teaching myself how to code and use these cool assets...

    I'm trying to find the best way to make my animal appear to wander by walking randomly. In my latest attempt, I'm going about it with the AnimalAIControl way of thinking.

    I've learned how to pick a random position on a NavMesh within a radius, but navHit.position is a Vector3. SetTarget() requires a Transform, not a Vector3. Any ideas how to make this work?

    Code (CSharp):
    1.     void NewWanderTarget() {
    2.         Vector3 randomDirection = Random.insideUnitSphere * wanderRadius;
    3.         randomDirection += this.transform.position;
    4.         NavMeshHit navHit;
    5.         NavMesh.SamplePosition (randomDirection, out navHit, wanderRadius, NavMesh.AllAreas);
    6.         goHere.transform.position = navHit.position;
    7.         animalAI.SetTarget(goHere);
    8.     }
     
    Malbers likes this.
  24. HeyBishop

    HeyBishop

    Joined:
    Jun 22, 2017
    Posts:
    238
    I've successfully gotten my animal to randomly wander around. After the animal finishes its walk to Vector3 goHere, it generates a new destination and goes there.

    Code (CSharp):
    1. public class WanderAI : MonoBehaviour {
    2.  
    3.     public float wanderRadius = 10f;
    4.     public float wanderResttimer = 15f;
    5.     public float wanderChangeDirectionDistance = 0.5f;
    6.  
    7.     private Animal animal;
    8.     private AnimalAIControl animalAI;
    9.     public Vector3 goHere;
    10.     private NavMeshPath path;
    11.  
    12.     void Start () {
    13.         animal = GetComponent<Animal> ();
    14.         animalAI = GetComponent<AnimalAIControl> ();
    15.         DoSomething ();
    16.     }
    17.  
    18.     void Update () {    
    19.         if (Vector3.Distance (transform.position, goHere) <= wanderChangeDirectionDistance || animalAI.Agent.isActiveAndEnabled && animalAI.Agent.isStopped) {
    20.             DoSomething ();
    21.         }
    22.     }
    23.  
    24.     public void DoSomething(){
    25.  // randomly choose an action, such as "eat", "dig", one of the idle animations, etc., or call the NewWanderTarget().
    26.        NewWanderTarget ();
    27.     }
    28.  
    29.     public void NewWanderTarget() {
    30.         Vector3 randomDirection = Random.insideUnitSphere * wanderRadius;
    31.         randomDirection += this.transform.position;
    32.         NavMeshHit navHit;
    33.         NavMesh.SamplePosition (randomDirection, out navHit, wanderRadius, 1);
    34.         goHere = navHit.position;
    35.         animalAI.AutoSpeed = false;
    36.         animalAI.SetDestination (goHere);
    37.     }
    38. }
    The change I want to make is: when it arrives at its destination, randomly call one of your animations. But, I don't know what animations are available, or what their ID int's are. Documentation says "Set an Action using their Action ID (Find the ID on the Animator Actions Transitions)", but I don't know what that means. Can you help me find each action ID?
     
    Last edited: May 12, 2018
    Malbers likes this.
  25. Malbers

    Malbers

    Joined:
    Aug 7, 2015
    Posts:
    2,558
    You can check the actions 2 ways:

    Looking to the Animator Transitions conditions for the Actions to know their IDs...
    upload_2018-5-7_10-18-19.png

    OR on any Action Zone there is an action Pack required:
    upload_2018-5-7_10-19-18 (1).png
    Which Holds the Actions IDs upload_2018-5-7_10-19-35.png
     
    Last edited: May 14, 2018
    Akshara likes this.
  26. Malbers

    Malbers

    Joined:
    Aug 7, 2015
    Posts:
    2,558
  27. Dymental

    Dymental

    Joined:
    Sep 14, 2014
    Posts:
    29
    Hi Malbers,
    Is there a pup version of the wolf like the other forest animals?
    And which grass asset are you using in your screenshot where grass is visible.

    Cheeers
     
  28. HeyBishop

    HeyBishop

    Joined:
    Jun 22, 2017
    Posts:
    238
    I can now! Thank you.
     
  29. HeyBishop

    HeyBishop

    Joined:
    Jun 22, 2017
    Posts:
    238
    I've got my animal wandering around fairly successfully. Unfortunately, sometimes it gets too close to and edge, and then it will slip and fall.

    I've tried making my agent radius bigger, smaller. I've put it on an child object and moved toward the front, to the centre. I've adjusted the NavMesh Max Slope and Step Height. Yet, this wolf always seems to fall eventually.

    Any suggestions on how I can prevent this from happening?

    In the video below, I demonstrate the problem I'm facing.



    (I've cross-posted here)
     
  30. fumeia2010

    fumeia2010

    Joined:
    May 5, 2018
    Posts:
    1
  31. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,199
    I really like these realistic rabbits. The other realistic animals can't come soon enough :D

    rabbits.jpg
     
    Team21Dev and Malbers like this.
  32. Malbers

    Malbers

    Joined:
    Aug 7, 2015
    Posts:
    2,558
    @Rowlan Awwwwww

    Here's some old new thingy
    Raven1.gif
     
  33. LaireonGames

    LaireonGames

    Joined:
    Nov 16, 2013
    Posts:
    705
    Sup! Do you have a roadmap or sorts for what your planning next?

    Would love to see things like a sheep or cow :)

    Guessing your are going to be busy doing a realism version overhaul and then a bird like you just posted but still curious what else is on your horizon
     
    Malbers likes this.
  34. KeithBrown

    KeithBrown

    Joined:
    Apr 1, 2017
    Posts:
    191
    LaireonGames likes this.
  35. Malbers

    Malbers

    Joined:
    Aug 7, 2015
    Posts:
    2,558
    This is the Current Road Map :)

    Raccoon.. (poly art and realistic)
    Young Dragon
    Wyvern
    Realistic Style for the animals (Wolf, deer, bear.... etc)

    Horse Animset Pro (Next big free update... Peggassus, more weapons.. more integrations)


    and then:
    Forest Birds (Crow/Raven, eagle, falcon, owl, sparrow...)
    Savahana
    Artic
    Farm
    Prehistoric

    The raven/crow is just one of the many things I have started :D:D:D:D and it will be released as well)
     
    Team21Dev, LaireonGames and Rowlan like this.
  36. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,199
    I really do miss a good and very well performing bird flock asset :D
     
    Malbers likes this.
  37. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,199
    Malbers and NatureManufacture like this.
  38. Dymental

    Dymental

    Joined:
    Sep 14, 2014
    Posts:
    29
    Nice screenshots just don't overuse motion blur :)

    We need Poly Art Racooooon :D
     
    Rowlan likes this.
  39. NatureManufacture

    NatureManufacture

    Joined:
    May 20, 2014
    Posts:
    2,023
    You forgot about the rocks:p? Looks nice :)
     
    Malbers likes this.
  40. Malbers

    Malbers

    Joined:
    Aug 7, 2015
    Posts:
    2,558
    Rowlan likes this.
  41. Malbers

    Malbers

    Joined:
    Aug 7, 2015
    Posts:
    2,558
    Another view for the Raven/Crow... The realistic one :) Forum.gif
     
  42. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,199


    I admit, I really do love how that realistic rabbit integrates with the scene and how it animates.
     
    Last edited: May 27, 2018
    HeyBishop and Malbers like this.
  43. helmers

    helmers

    Joined:
    Aug 28, 2010
    Posts:
    48
    Oh, the poor bunny must be quite exhausted after that run! Originally I wanted to use the bunnies as prey for the hunters in my RPG, but it seems they are way to cute that anyone would shoot them for food
     
    Malbers likes this.
  44. Rowlan

    Rowlan

    Joined:
    Aug 4, 2016
    Posts:
    4,199
    I thought similar about Unka the dragon. It doesn't necessarily have to be mean, my Unka is a good and nice and protective dragon :D
     
    Malbers likes this.
  45. Dymental

    Dymental

    Joined:
    Sep 14, 2014
    Posts:
    29
    With the Animal controller if my Fox is Idling (for example the ground sniff animation) the fox is gliding down on uneven terrain (i.e. ramps).
     
  46. Malbers

    Malbers

    Joined:
    Aug 7, 2015
    Posts:
    2,558
    Try setting a bigger value on the Fall multiplier parameter
    upload_2018-5-30_10-55-24.png
     
  47. darrennorthcott

    darrennorthcott

    Joined:
    Jun 17, 2014
    Posts:
    20
    Hey, I'm having an issue with the deer jumping. It seems to think it's hit an object mid-air and tries to land, then jump off again. I'm using polygon colliders as the floor... any ideas? (see video - last jump)

     
    Rowlan and Malbers like this.
  48. HeyBishop

    HeyBishop

    Joined:
    Jun 22, 2017
    Posts:
    238
    I don't have any insight to offer your problem, @darrennorthcott. But I would like to congratulate you on the look of your game in progress. It's gorgeous! Really, really beautiful work.
     
  49. darrennorthcott

    darrennorthcott

    Joined:
    Jun 17, 2014
    Posts:
    20
    Thanks! I'm hoping to refine it even more, but right now I'm struggling with the jumping and behaviour of the animal :(
     
    Malbers likes this.
  50. Malbers

    Malbers

    Joined:
    Aug 7, 2015
    Posts:
    2,558
    it is the same problem of the Fall Multiplier on the last post :(
    too short values will cause sliding...
    too long values will cause landing on the air...
    you need to tun it until it fit your game .... in your case you should set lower values .