Character Moves when Animating.

Started by thehivetyrant, Tue 23/03/2010 18:32:11

Previous topic - Next topic

thehivetyrant

Hi Matt here,
                    i have a character whose walking/standing animation is this size.


When you press the 'A' button he goes into an attack animation. Which is approximately this size.


I have some basic issue and questions involving this.

when I press 'A' he goes into the attack animation but the character moves to the right while he swings:
This is because it centers the image. and therefore his body is to the right of the attack image.

However if i extend the transparent area so he is always in the middle of every picture, then the collision detection goes way off as the enemies react to the transparent area next to him.

is there a way to set the image to the right or left?
Or possibly make it so enemies dont react to transparent pixels?


there are my thoughts on how to fix, if any other ideas fly in, i'll be sure to get my butterfly net out in time.

Thanks again,
                    Matt.

Matti

#1
Why don't you simply change the character's x coordinate when the A key is pressed? Something like character.x-=20.

Or make the fire blast (or whatever attack you want) an object/character that appears in front of the attacking character.

thehivetyrant

Hmm the latter option wouldnt work i dont think.
haha Its not a fireball it's a rough sketch of his sword swing. when i've finished the drawing that'll be his sword and it wont be at his side. Sorry for that confusion.

The i could probably do the first option you stated, moving his x co-ord while he's attack and then move him back?
I'd have to consider whether this could cause the enemies to have collision issues or not.

I'll give it a look at.

Khris

I'd have to say I'd probably never use the internal collision detection functions. They are to generic and inconvenient to be used for anything else than the most rudimentary collision detection.

If they work for you, go with Matti's advice, but I'd always use distances, collision boxes, several sprites, etc.

Matti

Yeah, I don't use the collision detection neither. In my current game I have a lot of collisions to check (mostly swordfights) and I always manually check the distance so that the characters are only getting hit when they actually collide with the sword.

thehivetyrant

Okay guys i think i've managed to solve it. (although i havent tested it using the animations in my original post yet)
For others that it might help.

I used the module found on this site called Pixel Perfect Collision.

- I had some issues when using it, my characters wouldn't collide at all
- I solved this by making the characters clickable (because of reasons it doesnt check unclickable characters)

and then

- the enemy would attack if my foot touched his head or vice versa.
-I solved this by going into the pixel perfect collison script and changing line 42:
int aheight = (Game.SpriteHeight[graphic]/4);

This changes the height at which it'll collide to 1/4 of the sprites height. You can change this of course.

Thanks for you help both of you.

GreenBoy



SMF spam blocked by CleanTalk