Follow mesh with inertia

Is possible to recreate the path of the demon like this video
(30) Warcraft 3 Reforged - Hungry Felhounds - YouTube
Here is my playground thanks!!
Follow demon | Babylon.js Playground

Here another test
Follow demon 2 | Babylon.js Playground

Hey @Abner_Corona.

My apologies. I’m not quite sure I understand the request here. Could you help elaborate a little bit about what you’re trying to do?

Thanks!

demon.position = BABYLON.Vector3.Lerp(demon.position, target.position, smoothingSpeed)

2 Likes

Based on the youtube video that @Abner_Corona shared I believe what is desired is bit of “slip and slide” and “over shooting” … a little “tokyo drift”. Whereas in the playground the demon follows the target a little too well, it’s right on top of it and the movement is completely straight and linear.

I’m not an expert at this but @Abner_Corona maybe try separating the rotation (lookAt) from the translation (follow) to have different “rates”. To me, it seems that the illusion of this deer slipping on ice comes from turning toward the target immediately (continue to update lookAt on every frame), but not updating position to target on every frame, or rather, maintaining the direction where it was previously going as if it can’t stop itself due to momentum.

Just an idea to try is using some setInterval that sets an animation on the demon to go where the target is, and just let it play out to move the demon from point A to point B over a number of frames with some easing function. On the next setInterval cancel the previous animation and create a new one, doing the same thing for the new target position and so on. That might make it seem like it’s so forceful in moving to a place that it can’t stop itself.

https://playground.babylonjs.com/#6YFZFB#11

2 Likes

https://playground.babylonjs.com/#6YFZFB#8 ← Move to

https://playground.babylonjs.com/#6YFZFB#9 ← Follow
https://playground.babylonjs.com/#6YFZFB#10 ← Caravan

There are ways to smooth it out even more, with the lookAt having a targetPositiong being lerped as well so they turn smoother. You can also work in inertia systems into this as well to make it way more realistic with motion.

1 Like

Thank you all I really appreciate it!!! if I finish my game I will give you the credits, honor to which honor deserves
Follow demon with a little slip and slide thanks | Babylon.js Playground (babylonjs.com)