How Set and Get animator controller (Blender 3D)

In TS or Blender Nodes.

Original Post on Discord

by user 736699881032384574

Hello there – we have an experimental AI bot :robot: 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…

Hello Ramon Xavier, it seems like you might have a question or issue related to development with TypeScript (TS) or working with Blender Nodes. Could you please provide more specific details about what you require assistance with? If you need help with scripting or implementing a feature in Needle Engine using TypeScript, or if there’s something specific within Blender that you’re trying to achieve with nodes, please elaborate so I can assist you effectively.

Here are a few tips on asking good questions in a development context:

  • Clearly describe the goal you’re trying to achieve.
  • Include any error messages or issues you’re encountering.
  • If relevant, share a snippet of your code or node setup but make sure it doesn’t contain any copyrighted material.
  • Specify what you have tried so far and the outcome of your attempts.

Providing this information will help me give you a precise and useful response.

1 messages left GPT 4
thread_GF6ODnZf9UhqeUuqxGiCWTbz
Thanks for your feedback!

example how set and get animator controller param

by user 736699881032384574

You can create a animatorcontroller like a new nodegraph.

Or do you mean how to set a parameter from typescript?

Tradução
i want to change the value of the variable when i press the button object. i created a button component in blender and i wanted to use a ts event to change the value.

by user 736699881032384574

Hi @Ramon Xavier what value do you want to change? Do you mean the animatorcontroller that is being used and assign a different animatorcontroller when you press the button or do you want to change a parameter in the animatorcontroller (e.g. set a bool parameter like running to true)?

yes. i want change a parameter in animatorcontroller when press a button. (set true or false for bools, set a number for ints)

by user 736699881032384574

What you can do is adding a custom component with a function (e.g. name the function “setSpeed”) that sets the parameter on the animator (by calling animator.setBool for example). You can then assign your button onclick event to call setSpeed in blender when you add your component to an object in the scene

can u write a full code example? :PandaEr:

by user 736699881032384574

I can write you a small example tonight. In the meantime you can checkout the examples here: Script Examples | Needle Engine Documentation on how to write scripts. Just create a field with an Animator reference and a method to call from your button that sets the bool on the animator (like: myFunction() { this.animator?.setBool("myBool", true) }

Tradução
I did it, thank you. But I still have a problem. The animation doesn’t change, even if I change the transition condition.

by user 736699881032384574

I’ll try again later

by user 736699881032384574

Here’s a small example:

export class AnimatorExample extends Behaviour {

    @serializable(Animator)
    animator?: Animator;

    @serializable()
    triggerName: string = "MyTrigger";

    setMyTrigger() {
        this.animator?.setTrigger(this.triggerName);
    }
}

that’s what I did

by user 736699881032384574

I’ll try it your way

by user 736699881032384574

I had the same problem. The variable changes, but for some reason the animation doesn’t.

by user 736699881032384574