#General advice on turn-based combat animation

19 messages · Page 1 of 1 (latest)

ornate gale
#

IDE: 4.2.1

I am trying to make a turn-based combat rpg.

The character's skills will have some animation such as swinging or thrusting, and during the skill, targets should have animation of getting hit.

I have no experience playing with animation stuff. Could anyone give me some advice?

The advice could be text, code, project, or link to tutorial/example.

plucky ferry
#

That's too broad of a question, not related to Godot's engine specifically. There is AnimatedSprite class for example that can handle animation states. You can move character sprite by changing it's position. You need to give it coordinates, where to move, you need to tell at which speed should it move, you need to block player input (or not) during movement. Animation is either spawning a new temporary object that deletes itself (queue_free) when animation ends (signals) or using shaders to affect enemy sprite itself.

tiny kindle
#

In my case I had a turn() function that calls character/enemy moves.

func turn() -> void:
  # 1. character moves first
  character.turn()
  
  # 2. check enemy is dead
  enemies.free_if_dead()

  # 3. enemy turn
  enemies.turn()

  # 4. some other things that needs to be applied

If animation is needed, you could seperate the value / animation code.

func turn_value() -> void:
  # same as above

func turn_animation() -> void:
  # implement animations only

This will ensure that values doesn't change while animation play, so If anything happens to the animation (such as, animation stopped because next turn is called), you'll be fine because the correct values were calculated in turn_value().

ornate gale
#

I see. So it is better to separate animation and other logic things.

Well, during these hours of investigation, I kinda thought that I could use animation player to sync animation of skill and animation of getting hurt.
Say there is a skill will attack same target twice. I thought that maybe the animation of attacking could call method of getting hit at very exact time so that the graphic looks good.

You kinda remind me that these animations are running asynchronously.

Before I started separate these two things, do you know how to bind args to the call method track so that I could let the skill animation launch getting hurt animation on the target.

plucky ferry
#

callable.bind(argument)

#

signal.connect(callable)

ornate gale
#

I tried something like this:

ornate gale
#

Will the await prevent the animation from getting interrupted?

ornate gale
plucky ferry
#

Also, I am not sure if you need var c.

hit.bind(target)
$AnimationPlayer.hit.connect(hit)
...
$AnimationPlayer.hit.disconnect(hit)

#

Method/function is already deriving from callable if I am not mistaken (it's it's base class)

ornate gale
#

Actually I am not sure if binding will have some side effect.
I am afraid that if I bind an arg to the method, it will remember the arg all the way.
I think I am going to test this tomorrow since it's too late here.

plucky ferry
ornate gale
#

I think bind() returns a new callable and charge won't know anything about it.

#

Which is intuitive for me.

#

But I got confused for this:

#

It said that I was trying to bind same callable.