Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Why does my player character grow in size when moving sideways ?

Explorer ,
Mar 03, 2018 Mar 03, 2018

Hey,

I'm creating a small game for an assignment. I've created it, and now i'm adding the graphical and animation parts to it. My main character is a bird, and I wanted to add some simple animation to it, and I managed to do it, however, when moving left/right, the character grows in size and I'm not sure why. I've made a video to showcase what's happening. Game animation and hitbox bug - YouTube

Does anyone know how I can fix this? The way I did it was by creating 2 symbols, one for idle, one for running, but the animation in both is the same, then given then names, and called them when certain actions are done in the game to change the animation state. The hitboxes also seem a bit broken with this character 😕

696
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 04, 2018 Mar 04, 2018

one way to do that would be to create a bird movieclip and create one or more keyframes in that (bird) movieclip.  one bird keyframe might be a resting bird.  that might even be a movieclip of a bird that periodically scratches his head.  one keyframe might contain a movieclip of a bird with flapping wings.

you would use bird.gotoAndStop() to control which keyframe (resting or flying) is displayed.

Translate
Community Expert ,
Mar 03, 2018 Mar 03, 2018

if you're using code to control your bird your scaleX property should be 1 or -1.

if you're using the time, check the transform panel with your bird selected on all the keyframes.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 04, 2018 Mar 04, 2018

I've checked my code, and this is what I have:

if(leftPressed){ //If the left key is pressed

xSpeed -= speedConstant; //xSpeed = xSpeed variable - speedConstant variable

player.scaleX = -1; //Makes the player face the left side

} else if(rightPressed){ //If the right key is pressed

xSpeed += speedConstant; //xSpeed = xSpeed variable + speedConstant variable

player.scaleX = 1; //Makes the player face the right side

}

It seems correct to me, and I don't have any other code relating to player scaleX.

I've also checked the transform tab, and I don't exactly know what i'm looking for. It's the same for both when the player stands still and moves, and when I actually play the animation from the place where I created it, it works fine, but it's just in the game where it becomes wider than it should be.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 04, 2018 Mar 04, 2018

click the transform tool and then select your bird.  make sure the circle (transform point) is in the horizontal center of your bird.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 04, 2018 Mar 04, 2018

I think this is what you mean https://imgur.com/gallery/dvImX

I've checked it at all of the keyframes, and the circle is in the horizontal middle in all of them 😕

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 04, 2018 Mar 04, 2018

don't see a problem there.

you could also be scaling a parent of the bird and that would cause a problem.  but i don't think this is going to be remedied via a forum.  someone will probably need to download your file to debug it.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 04, 2018 Mar 04, 2018

Would you be able to take a look if I uploaded it somewhere?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 04, 2018 Mar 04, 2018

i only download and correct files if i'm hired.

if you're patient, others may do that for free.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 04, 2018 Mar 04, 2018

Ah I see, fair enough.

Do you know if there is any other ways of doing the animation? As the way I've done it now is gone inside the player symbol, and in there, created two separate symbols called "Player Animation Idle" and "Player Animation Running", and inside those symbols I did the animation itself, but it's the same in both since I just want flapping wings. Is this the usual way to do it or is there another way, which may perhaps solve it?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 04, 2018 Mar 04, 2018

one way to do that would be to create a bird movieclip and create one or more keyframes in that (bird) movieclip.  one bird keyframe might be a resting bird.  that might even be a movieclip of a bird that periodically scratches his head.  one keyframe might contain a movieclip of a bird with flapping wings.

you would use bird.gotoAndStop() to control which keyframe (resting or flying) is displayed.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 04, 2018 Mar 04, 2018

I've managed to  fix it, I completely reset it to the character I had before, removed everything to do with it, removed the code for animation states I had, did the animation the way you said to do it in the previous post and it works!


The only problem i'm seeing is that the hitboxes between the player and obstacles aren't exactly amazing, but it's playable and possible to finish all three levels.

Thanks a lot

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 04, 2018 Mar 04, 2018
LATEST

you're welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines