Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1038215 Posts in 41955 Topics- by 33579 Members - Latest Member: Wormkout

September 02, 2014, 05:58:42 AM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)Weird animation bug?
Pages: [1] 2
Print
Author Topic: Weird animation bug?  (Read 484 times)
Rabbit
Level 10
*****


i can do what i want

TheRabbitInferno
View Profile WWW Email
« on: April 06, 2013, 09:25:43 AM »

So here is my situation.

When you are aiming (holding the gun up and looking down the sight) the movement animation changes and movement slows down. The problem I currently have is that when aiming and moving to the right, the animation won't play. It just gets stuck on the first frame.

However, if you move to the left the animation will play in reverse as it should. After moving left, and then moving right again, the animation WILL PLAY but only as many cycles as it had previously played in reverse. Here is an example followed by the code I have in place.


(yeah when facing left the animations don't play correctly but I know how to fix it)

Code:
if (aim && onGround && !crouch){
    sprite_index = sRedAim;
    image_speed = 0;
    xSpeed = 0;
         if (left){
            sprite_index = sRedAimMove;
            image_speed  = -0.2;
            xSpeed       = -1;
        }else if (right){
            sprite_index = sRedAimMove;
            image_speed  = 0.2;
            xSpeed       = 1;
        }

I actually need a bit more help in terms of animation for this project and I am willing to pay for a tutor essentially. But yeah. All help is greatly appreciated!
Logged

put on these sunglasses or start eatin that trashcan
soryy708
Level 3
***


Where is my tea?


View Profile Email
« Reply #1 on: April 06, 2013, 10:23:59 AM »

Alittle bit more code could be useful.

Please note that a bug that seems to come from one system actually originates in another  Gentleman

To begin with, your currently posted code looks okay (at first glance atleast). The problem's likely somewhere else.
Logged

Portfolio:
  • Cacto Loco! - 'Additional Tunes' (Composer)
  • To be continued...
Rabbit
Level 10
*****


i can do what i want

TheRabbitInferno
View Profile WWW Email
« Reply #2 on: April 06, 2013, 10:55:06 AM »

Its actually the only code that is in use, as I've commented out the rest for testing. However here is his entire movement/animation code.

Code:
//movement//
if (aim && onGround && !crouch){
    sprite_index = sRedAim;
    image_speed = 0;
    xSpeed = 0;
         if (left){
            sprite_index = sRedAimMove;
            image_speed  = -0.2;
            xSpeed       = -1;
        }else if (right){
            sprite_index = sRedAimMove;
            image_speed  = 0.2;
            xSpeed       = 1;
        }
}else if (left){
    image_xscale = -1;
    sprite_index = sRedRun;
    image_speed = 0.5;
    xSpeed = -6;
}else if (right){
    image_xscale = 1;
    sprite_index = sRedRun;
    image_speed = 0.5;
    xSpeed = 6;
}else if (crouch && onGround && !aim){
    sprite_index = sRedCrouch;
    xSpeed = 0;
}else{
    sprite_index = sRedStand;
    xSpeed = 0;
}
Logged

put on these sunglasses or start eatin that trashcan
ஒழுக்கின்மை
Level 10
*****


Also known as रिंकू.

RinkuHero
View Profile WWW Email
« Reply #3 on: April 06, 2013, 11:11:14 AM »

that still isn't all the code. you aren't explaining how left and right and aim and onground and crouch are set, for example. you aren't showing the code for setting and unsetting those variables
Logged

Rabbit
Level 10
*****


i can do what i want

TheRabbitInferno
View Profile WWW Email
« Reply #4 on: April 06, 2013, 11:12:16 AM »

Okay. Here is this.

Code:
left    = (keyboard_check(ord("A")));
right   = (keyboard_check(ord("D")));
aim     = (keyboard_check(ord("W")));
crouch  = (keyboard_check(ord("S")));

This simply sets left/right/aim to true or false. All input works this way.

In another script that gets called in Create, along with all of the player variables, these are all set to "false" by default.

And here is how onGround is defined, along with some other things.

Code:
//vertical collision//
if (place_meeting(x,y+ySpeed,oBlocker)){
    while (!place_meeting(x,y+sign(ySpeed),oBlocker)) y += sign(ySpeed);
    ySpeed = 0;
    onGround = true;
}else if (place_meeting(x,y+ySpeed,oBlock)){
    while (!place_meeting(x,y+sign(ySpeed),oBlock)) y += sign(ySpeed);
    ySpeed = 0;
    onGround = true;
}else{
    sprite_index = sRedJump;
    onGround = false;
}
« Last Edit: April 06, 2013, 11:25:04 AM by Rabbit » Logged

put on these sunglasses or start eatin that trashcan
ஒழுக்கின்மை
Level 10
*****


Also known as रिंकू.

RinkuHero
View Profile WWW Email
« Reply #5 on: April 06, 2013, 01:20:55 PM »

have you used debug mode yet, with all of those variables listed, to see if there's any difference between the two situations you mention (aiming + moving left vs aiming + moving right)? make sure sprite_index and image_speed are included in that debug variable list
Logged

Rabbit
Level 10
*****


i can do what i want

TheRabbitInferno
View Profile WWW Email
« Reply #6 on: April 06, 2013, 02:07:07 PM »

have you used debug mode yet, with all of those variables listed, to see if there's any difference between the two situations you mention (aiming + moving left vs aiming + moving right)? make sure sprite_index and image_speed are included in that debug variable list

I have not. I dunno how debug mode works in Studio. I know nothing. I am a baby.
Logged

put on these sunglasses or start eatin that trashcan
ஒழுக்கின்மை
Level 10
*****


Also known as रिंकू.

RinkuHero
View Profile WWW Email
« Reply #7 on: April 06, 2013, 02:08:41 PM »

i think it works the same way it does in gm7 last i checked -- you just run in debug mode (the red arrow) and type in the variables you want to track
Logged

Rabbit
Level 10
*****


i can do what i want

TheRabbitInferno
View Profile WWW Email
« Reply #8 on: April 06, 2013, 02:25:32 PM »

I will try that. I've never used it in any version of GM honestly. Everything I've worked on has been simple enough to just know what is happening haha.

Aha! So here is what is happening, though I don't know why.

Left, right, aim, etc are all firing as they should. Changing from 1 to 0 and 0 to 1 when appropriate. What I have found is that when aiming, and moving right, the image index does not increase which is effectively keeping the sprite from animating.

When aiming and moving left however, the sprite index starts decreasing infinitely until you push aim and right. At which point it starts increasing until it hits 0, and stops.

It is not simply cycling the number of frames in the animation like it should be. For example when running, the index climbs from 0 to 15 and then resets back to 0 to loop the animation. This is not happening.
« Last Edit: April 06, 2013, 02:35:19 PM by Rabbit » Logged

put on these sunglasses or start eatin that trashcan
ஒழுக்கின்மை
Level 10
*****


Also known as रिंकू.

RinkuHero
View Profile WWW Email
« Reply #9 on: April 06, 2013, 04:10:08 PM »

going infinitely negative isn't a problem because GM uses "mod" to determine which to use. in other words, if a sprite has 15 frames, numbered 0 to 14, it does "image_index mod 15" which always keeps it in the range between 0 and 14

not increasing when it should is probably the problem. when it doesn't increase, and it should increase, is image_speed 0, or 0.2? according to your code, when you want image_index to increase, image speed should be 0.2. when the animation doesn't increase when you want it to increase, what is image_speed's value?
Logged

Rabbit
Level 10
*****


i can do what i want

TheRabbitInferno
View Profile WWW Email
« Reply #10 on: April 06, 2013, 04:49:52 PM »

image_speed is acting as it should. its set on 0.2 and when moving left its -0.2.

I took a cap of the stats in motion. I dont know if I may be missing something.

Logged

put on these sunglasses or start eatin that trashcan
ஒழுக்கின்மை
Level 10
*****


Also known as रिंकू.

RinkuHero
View Profile WWW Email
« Reply #11 on: April 06, 2013, 04:55:45 PM »

you said above that the image_index doesn't increase; but it is increasing in that gif (it's going from a higher negative number to a lower negative number, which is an increase)
Logged

Rabbit
Level 10
*****


i can do what i want

TheRabbitInferno
View Profile WWW Email
« Reply #12 on: April 06, 2013, 04:59:26 PM »

you said above that the image_index doesn't increase; but it is increasing in that gif (it's going from a higher negative number to a lower negative number, which is an increase)

Well right but it will not increase beyond 0.2~8 or whatever it is. So its not animating when moving forward.

Compare this to the basic running sprite. It increases from 0 to 15, then resets back to 0 to repeat as long as necessary.
Logged

put on these sunglasses or start eatin that trashcan
ஒழுக்கின்மை
Level 10
*****


Also known as रिंकू.

RinkuHero
View Profile WWW Email
« Reply #13 on: April 06, 2013, 05:49:18 PM »

do you mean that image_speed reverts to -0.2 from 0.2 when image_index reaches around 0, or what?
Logged

Rabbit
Level 10
*****


i can do what i want

TheRabbitInferno
View Profile WWW Email
« Reply #14 on: April 06, 2013, 05:58:33 PM »

I can pack this into a zip and let you check it out if you'd like.
Logged

put on these sunglasses or start eatin that trashcan
Pages: [1] 2
Print
Jump to:  

Theme orange-lt created by panic