#..

1 messages · Page 1 of 1 (latest)

shadow kettle
#

use query.has_target in an animation controller

hollow gulch
#

lemme paste it then

hollow gulch
#

im not an expert in this

#

oh u mean the ac folder right

hollow gulch
# shadow kettle use query.has_target in an animation controller

sorry to bother you but this is my ac for attack

            "initial_state" : "default",
            "states" : {
                "attacking" : {
                    "animations" : [ "attack.rotations" ],
                    "transitions" : [
                        {
                            "default" : "variable.attack_time < 0.0"
                        }
                    ]
                },
                "default" : {
                    "transitions" : [
                        {
                            "attacking" : "variable.attack_time >= 0.0"
                        }
                    ]
                }
            }
        },```
#

how to add the query to it

shadow kettle
# hollow gulch how to add the query to it

I wanna see if you can figure it out first before I tell you.
y'know, like the old saying, "give a man a fish, teach a man to fish".


Controller animations define when you use an animation.

initial state will be the first state that your entity goes to.
As your intitial state is "default", your controller animation will start there.
Since there is no animations in default, nothing will happen.

Your other animation state is "attacking".
That state has an animation called "attack.rotations", so when your current state is "attacking", the "attack.rotations" animation will play.

To get from the "default" animation state to the "attacking" animation state, it has to transitition there. That's what the transition section is for.
Transitions tell you what has to happen in order to change from one state to the other.


So with all that said, where do you think you should put "query.has_target"?

hollow gulch
#

alright im looking through the docs too lemme see if i can do this

hollow gulch
shadow kettle
#

yep, that's correct
"transitions" : [ { "attacking" : "query.has_target" } ]

#

And once you're in the "attacking" state, you'll want to be able to go back to the "default" when there is no longer a target, which means the opposite of "query.has_target".

You use "!" to get the opposite of a query, or if there is 0 of something.

So you use "!query.has_target" for the transition to default. @hollow gulch

hollow gulch
#

i see, and do i still need the variable.attack_time in both transitions like with && @shadow kettle

shadow kettle
#

You don't need it for your purposes. You said you want your character to do the attack animation all the time so long as it has a target to track.

variable.attack_time is just a variable that activates when a mob is attacking.

So when a mob is attacking, the variable number goes up, and when the number is greater than 0, it transitions to the attacking state.

When a mob is no longer attacking, the variable goes back down to 0, meaning it transitions back to default.

hollow gulch
shadow kettle
torpid glade
#

..

hollow gulch
# shadow kettle Might have to do with the fact that you're using attack.rotations rather than yo...

ok so i kinda have an attack animation similar to player's attack animation, here it is

            "loop" : true,
            "bones" : {
                "body" : {
                    "rotation" : [ 0.0, "variable.attack_body_rot_y", 0.0 ]
                },
                "leftarm" : {
                    "rotation" : [ "-(math.sin((1 - math.pow((1 - variable.attack_time), 4)) * 180) * 1.2 + math.sin(variable.attack_time * 180)) * 10.0", 0.0, 0.0 ]
                },
                "rightarm" : {
                    "rotation" : [ "-(math.sin((1 - math.pow((1 - variable.attack_time), 4)) * 180) * 1.2 + math.sin(variable.attack_time * 180)) * 30.0", "-(math.sin((1 - math.pow((1 - variable.attack_time), 4)) * 180) ? (-90.0 * math.sin((1 - math.pow((1 - variable.attack_time), 4)) * 180)) + 30.0 : 0.0)", 0.0 ]
                }
            }
        },```