question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How do you get an arbitrary model to walk around with animation?

See original GitHub issue

Demo video

You can see in this video, the sheep models just float from one location to the next without any sort of walking animation. The code that updates their positions looks like this:

function walkSheepToNewLocations(directions, delta) {
      for (let i = 0; i < sEnv.num_sheep; i++) {
          sheepModelInstances[i].setSequence(sheepWalkSeq, true) // using that boolean extra arg introduced in PR https://github.com/flowtsohg/mdx-m3-viewer/pull/69
          sheepModelInstances[i].move([directions[i][0] * delta, directions[i][1] * delta, 0] )
      }
}

What’s weird is I never came across this issue when animating a single Grunt model walking. I would merely set the sequence to the walk value and then start calling gruntModelInstance.move([delta_x, delta_y, 0]).

With the sheep it doesn’t matter if I remove sheepModelInstances[i].setSequence(sheepWalkSeq, true) from the for-loop or not, they still just float around.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:53 (25 by maintainers)

github_iconTop GitHub Comments

2reactions
flowtsohgcommented, May 8, 2021

Pushed a bunch of changes I had stacking up over a long time, one of them is a simple example of how to add state to the units and doodads so you don’t have to do weird hacky things to not get the automated stand animations.

For example if you have your sheep in map.units, you can do sheep.state = WidgetState.WALK (from widget.ts) and it won’t run the stand animations.

1reaction
flowtsohgcommented, May 5, 2021

It’s not much, but I finally get how to read stuff. No time to do with it anything for now though.

Maybe I’ll figure a nicer way to read strings… (not for tags since I’ll use u32 for those, but rather for actual strings)

pub fn load_file(&self, buffer: Box<[u8]>) -> u32 {
    let mut cursor = Cursor::new(&buffer);
    
    // capacity=4 doesn't mean there are actual bytes on the heap, gotta have a real value
    let mut mdlx = String::from("AAAA");
    unsafe {
        cursor.read(mdlx.as_bytes_mut()).expect("NOPE");
    }

    let mut vers = String::from("AAAA");
    unsafe {
        cursor.read(vers.as_bytes_mut()).expect("NOPE");
    }

    // using the byteorder crate
    let size = cursor.read_u32::<LittleEndian>().unwrap();
    let version = cursor.read_u32::<LittleEndian>().unwrap();

    version
}
console.log(v.load_file(new Uint8Array(buffer))); // 800
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to animate a walk cycle in After Effects - YouTube
In this tutorial we'll be looking at making our character walk ! Get The "Lyric Video Creator Kit" Here: https://bit.ly/3lfC2Ab​What's ...
Read more >
Entity Modeling and Animation | Microsoft Learn
Open the model and switch to the Animate tab in the top-right corner. Create a new animation in the Animations panel on the...
Read more >
Create 3D graphics in Animate - Adobe Support
To move the object using the Property inspector, enter a value for X, Y, or Z in the 3D Position and View section...
Read more >
Matplotlib animations the easy way - Brushing Up Science
This example walks through how to create the animation below in six steps. ... Well, it's not actually arbitrary, it's set up to...
Read more >
Animating Arbitrary Objects via Deep Motion Transfer - arXiv
Given an input image with a target object and a driving video sequence depicting a moving object, our framework generates a video in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found