blender saves an animation for each object. But blender plays them all simultaneously. how can I do the same using the addon or TS?
by user 736699881032384574
blender saves an animation for each object. But blender plays them all simultaneously. how can I do the same using the addon or TS?
by user 736699881032384574
Hello there – we have an experimental AI bot that might be able to help you with your question. Would you like to try this out?
How it works:
Reply to the messages of the bot that end with a thread_id
to interact with it and ask follow-up questions. You can also mention the bot directly in this channel to get help.
Help requested: please wait a moment…
Here is what I found for you Discord
Ramon, to play animations from Blender simultaneously in Needle Engine, similar to how it is done in Blender, you’ll need to ensure animations are set up correctly in Blender before exporting. Needle Engine will play animations on each object as dictated by the animation clips associated with those objects.
Here’s a step-by-step guide in TypeScript to play animations:
Animation
or Animator
component to each object in TypeScript.Below is a TypeScript example to play an Animation Clip (assuming you have the animation clips referenced already from Blender):
import { Animation, Animator, Behaviour, serializable } from '@needle-tools/engine';
import { AnimationClip } from 'three';
export class PlayAnimationsSimultaneously extends Behaviour {
@serializable(AnimationClip)
private animations: AnimationClip[]; // Array of AnimationClips from Blender
start() {
this.animations.forEach(clip => {
const animation = this.gameObject.addComponent(Animation);
animation.addClip(clip);
animation.play(clip.name);
});
}
}
Place this script on the parent object or on each object that has an animation. Ensure that each object has its own AnimationClip
referenced.
Furthermore, for networking events and clicks, you can use the provided component-click-networking.ts
example from the documentation which sends the received click to all connected clients, allowing you to respond to click events, such as playing animations across the network (see the documentation).
1 messages left GPT 4
thread_mgvCZ25uA2PeDqDzjTD6tii2
Thanks for your feedback!
ty boot. ill try latrr
by user 736699881032384574
Hello Ramon, to assist you effectively, could you please specify what you’re trying to achieve or what example you’re referring to? If it’s related to scripting, component usage, or any other feature in the Needle Engine, please give me a bit more context so I can provide you with the appropriate example or guide you through solving the issue.
1 messages left GPT 4
thread_P9kih9fn0aSKIo8H1UDoGhKp
@Ramon Xavier hi, do you mean you want to play all animations on all objects immediately in the browser?
i want play all when i touch a button and turn off when i press again
by user 736699881032384574
You can add the „Animation“ component to objects and assign which tracks play on them. Then from a script or from events on a button can play on the ones you want to play
i try it. but sometimes its get erro.
by user 736699881032384574
import { Behaviour, PlayableDirector, serializable} from ‘@needle-tools/engine’;
export class startAnimation extends Behaviour {
@serializable(PlayableDirector)
an?: PlayableDirector;
setAnimation(){
if(this.an){
if(this.an.isPlaying){
this.an.stop();
}
else{
this.an.play();
}
}
}
}
by user 736699881032384574
doesn’t just work on the main component.
but I want to be able to control the main component together with the other components.
by user 736699881032384574
I’ve thought of other solutions but I haven’t had time to redo it yet.
by user 736699881032384574
I did it.
just to clarify.
I was trying to animate the same object as I was using the button component.
I had to put the programming above and the click button on another empty object
by user 736699881032384574
here’s my solution for anyone who needs it. if there are other, easier ways, please share.
by user 736699881032384574
import { Behaviour, PlayableDirector, serializable} from ‘@needle-tools/engine’;
export class setAnimation extends Behaviour {
@serializable(PlayableDirector)
animation?: PlayableDirector;
animationBegin(): void{
this.animation?.forEach(x => {
if(x){
if(x.isPlaying){
x.stop();
}
else{
x.play();
}
}
});
}
}
by user 736699881032384574
Glad you got it to work Thanks for following up!