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:
The second script in the step event:
Then in my timeline I have the following.
Step 0:
Step 15:
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?
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";
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;
};
Step 0:
Code:
object_state = "jumping";
hspeed = 0;
Code:
hspeed = jump_speed * facing_direction;
vspeed = -jump_height;
timeline_index = -1;