How to animate and move a mesh?

Good Evening Babylon.js Creators

Would anybody know how to move a mesh and animate it? Like a walk cycle. The mesh moves and animates at the same time.

In my playground scene, I’m trying to move my robot by calling functions so that they can animate and move but for some reason, only my forward’s animation is working?

Would anybody be able to help me if possible, please?

Hi,
I am not a specialist of animationGroups and imported animations but one thing I already detected here is that your forward animation just never stops. I don’t have time right now and others would be more qualified than I am to fix this, but I’d say if you would already not have all your animations in a separate function and if you would add a keyUP to stop the animation (or even stop the forward animation when you start the backward animation) and/or return the idle state as the start of your new animation, things would already work a lot better I suppose.

Edit: As I said I don’t know much about animationGroups and imported anims, but I quickly just did this change in your PG simply to illustrate two things:

  • First thing is that you are starting all of your animations instead of stoping them, at first. So all animations are running (backward and forward). Obviously this will not work
  • Second is that the way you build your animations in scene makes them unavailable.

Finally, I believe the idle animation isn’t doing anything (or may be it will later on) but I believe more essentially what you would need is an idle state; in other words, a variable that will record the latest state of your combined animations and use this as the start for a new one.
I hope someone will soon kick-in for you and provide better insight. Else, you can still have a look at the doc. There is some documentation about how to actually make a vehicle move. I had a look at it but never had the chance (or opportunity) to exercise it. May be one day… Meanwhile, have a great day,

Hi, mawa so sorry for getting back to you so late. Thank you so much for all your help. I really appreciate it. Your help is a big step forward. I’m going to continue checking out what i can find about the combined animations as you discussed and also the car hope I can get it to work.

By any chance when you have time do you know where I can find that car documentation?

Sure, no worries. I believe for your use case and an entry-level study (a car is quite complex), there is this workshop serie that might be appropriate:

Edit: Here’s an old PG for you that should actually do most of the job for just moving around your little robot. You would still need to add your animations of rotating and turning wheels to it but it could save you a big part of the work to make it move in scene.

The old thread is to be found here:

Else, if you search through the forum with the words of ‘car’ or ‘vehicle’ you will find more.
Hope this helps, GL with your project (the small robot is cute :smiley:

I recommend taking a look at this too Animating Characters | Babylon.js Documentation (babylonjs.com) :slight_smile: