#Changing collisions by frames for an attack animation.

23 messages · Page 1 of 1 (latest)

pallid orchid
#

Hi! I was working on animations for my game and I ran into an issue. For context I use CharacterBody2D and AnimatedSprite2D. I want to make the collisions change at a character’s slash animation frame, but I don’t know how to go about this.

I can’t seem to use AnimationPlayer/Tree either because that requires a sprite sheet, and my sprite sizes for the different animations are vastly different and would clash if put into a single sprite sheet.

verbal girder
#

How different are the sizes exactly? Is it possible for you to put all the animations in a consistent sprite sheet given a large enough size?

#

Also I don't think AnimationPlayer always requires a sprite sheet if I recall - I was able to make color-changing and collision enabling/disabling animations for a Sprite2D with just one sprite using an AnimationPlayer node

pallid orchid
#

Pretty different. Some sprites are really big compared to others. Also, how? From what I saw spritesheets were the only way

verbal girder
#

You'll need to put in a spritesheet if you use frame-related property (e.g. h_frames) but if you don't you can probably just assign a position-related property (forgot the exact name) to CollisionShape2D and add keyframes

#

'Sec, lemme open up an old project

pallid orchid
#

Can I do this with AnimatedSprite2D?

verbal girder
#

I don't think you can, that one is for spritesheets only I think

#

Oh here it is

#

This screenshot shows me making an animation where the sprite changes its colour

#

AnimationPlayer, no spritesheets, just attached a single Sprite2D with a self_modulate property and add keyframes at time positions

#

If want my sprite to go from blue to red within 2 seconds for example I just put the blue keyframe at 0 and red keyframe at 2

#

I think CollisionShape2Ds should work the same way, you use the Node2D/position property and add keyframes, then change the position's value

#

Though you also have to consider the direction the player is facing so you don't have a guy facing right but the attack hitbox is left

#

Sorry it's been months since I used Godot xd

#

If you want to change the texture just use the Sprite2D/texture property

pallid orchid
#

Interesting! So the sprites don't need to be the same size either?

verbal girder
#

Nope, but you may have to re-center them yourself with a position property if the sizes are so different

pallid orchid
#

Bte the difference I'm talking is 100 more height and 40 width than the base sprite. That's for one attack.

verbal girder
#

It should be fine

pallid orchid
#

And the walking animations are different too based on direction.

verbal girder
#

You just gotta do some readjustments, I don't know the specifics of your sprites but anything's possible

pallid orchid
#

That's why I can't put them all in one spritesheet ;-;