The hacking game from NieR: Automata

The background objects and the different types of projectiles and obstacles are using InstancedMesh. So each group of objects is rendered with a single draw call.

I’m not using an external library for animation. Everything is updated in the animation loop.

1 Like

Can you post (if you agree :slight_smile: ) an example of this animation in your loop function?

Between 11 second and 13 seconds (the explosion of your dark particles).

It doesn’t have to be exact, just the principle if you like…for this kind of effect I use tween.js and I’m curious to see how it is done in a loop function

@espace3d The simplest implementation of a tween is something like this:

const animation = {
	progress: 0,
	duration: 2
}


function update( deltaTime ){

	// update the animation progress
	// it's a percentage, so will be in the interval [ 0, 1 ]
	animation.progress += deltaTime / animation.duration 

	// make sure we don't overshoot the end of the animation
	if ( animation.progress > 1 ) animation.progress = 1 

	// update whatever it is you're animating 
	someObject.position.lerpVectors( startPosition, endPosition, animation.progress )

	// animation is finished
	if ( animation.progress === 1 ){
		
	}
}

Essentially, you’re animating the progress of the animation from 0 to 1, and using that value to control the animated objects.
You can then add some logic to delete the animation when it’s done, add callbacks for the start / end of the animation, add some easing to the animation.progress value when you’re using it to animate in order to make it look more interesting…

Then when you need more complex behaviour you can start developing ways to chain animations together, reverse them, loop them etc.

I’d suggest having a look at gsap, it’s quite a standard library to use and is AFAIK a lot more powerful than Tween.js

Thanks a lot for these explanations. I will try.

Sorry, this is a bit of of scope :sweat_smile: . I’m not sure how the original developers done it but you could get comparable results by using a particle system with a custom effect.

1 Like

By the way, when you originally posted this you inspired me to play Nier Automata and it’s one of the best games I have played years so thank you :smile:

1 Like