Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+1)

Thank you very much for the guide! Could you let me know how you got animations to work when moving between tiles, rather than snapping?

 Sure! Basically, I use a Tween node to handle the animations. The Tween node might as well be my favorite node, it really, really is veeeeeeeeeeery useful. If I had one, I would use a t-shirt saying how much it is useful.

 Anyway, in this case, you'll be using it more or less like this:

if bCanMove:
    # Change the actor state to "Moving", and clears the cell where it is currently at
    state=States.Moving
    self.freeAStarGrid()
    # Setups the animation properties and starts it
    $tween.interpolate_property(self,"global_position",self.global_position,vTarget,0.2,Tween.TRANS_QUINT,Tween.EASE_IN_OUT)
    $tween.start()     # Waits for the animation to end, changes the state to "Stopped", and occupies the cell the actor is currently at
    yield($tween,"tween_all_completed")
    state=States.Stopped
    self.occupyAStarGrid()

 The lines where the animation is setup and started are the ones that start with $tween.

 So, the interpolate_property() method might seem a bit daunting, but once you start using it, it will make a lot more sense. Putting it simply, it takes a bunch of arguments that'll say things like the duration of the animation, its beggining, end, etc. Here's a brief description of the most relevant ones:

  1. First we pass the object which will have one of its properties changed. In this case, the object is the actor itself;
  2. Then, we pass which property will be changed as a string. In this case, it'll be the global position, which as a string is just "global_position";
  3. Then, we pass the starting value. For the global position, it'll be the actor current position;
  4. After that we pass the target value, and for the position, yeah, it will be the position we want the actor to move towards;
  5. Now, the duration in seconds. I try to keep this under 0.5 seconds, since animations that take too long might end up being annoying;
  6. Then, we have the transition type. Basically it is the major "style" of the animation... you can check what type look like in this website;
  7. Finally, we have the easing type. It also affects the style of the animation, and the website I mentioned on step 6 also should help you understanding it.

 You can also use tweens to control properties such as transparency, color, scale, and rotation!

 I hope I helped you a bit more! Thanks for reading this guide too, glad to be helpful!

(+1)

Thank you kindly for the detailed reply! You've also brought to my attention that I should be making my life easier with a State Machine hehe. Cheers :D