• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

[SOLVED] First time using timelines. Something isn't triggering here.

S

ShilohPell

Guest
Alright, so I have two scripts in an enemy object called a blob. The blob's desired behavior is to wander around on its platform and, when it sees the player, it pauses for 15 frames and then jumps at them. Here's the first script in the step event:
Code:
///Set state
if(object_state == "wandering") && (player_sighted == true) object_state = "jump";
if(object_state == "jumping") && (collision_down) && (timeline_index == -1) object_state = "wander";
The second script in the step event:
Code:
///Perform State

switch (object_state)
{
    case "wander":
        if(afraid_of_heights) && (collision_down) && !position_meeting(x + (sprite_width / 2), y + (sprite_height / 2) +3, obj_solid)
            {
                facing_direction *= -1;
            };
        break;
    case "jump":
        timeline_index = tl_blob_jump;
        timeline_position = 0;
        timeline_running = true;
        break;
    case "jumping":
        //Do nothing
        break;
};
Then in my timeline I have the following.

Step 0:
Code:
object_state = "jumping";
hspeed = 0;
Step 15:
Code:
hspeed = jump_speed * facing_direction;
vspeed = -jump_height;
timeline_index = -1;
The resulting behavior is that my blob moves back and forth on its platform and never leaves the "wander" state. I've slipped in some debug code so it displays whether it sees me and it does but it never changes its state to "jump" so I'm not sure what I'm doing wrong here. Any help?
 
S

ShilohPell

Guest
Update: Here's a screenshot of the debug mode. The top line displays its state and the bottom line shows string(player_sighted)
 
S

ShilohPell

Guest
Additional update: Yes, I'm a moron. I just realized I was setting it to "wander" and checking for "wandering" I fixed it.
 
Top