Zachary_Alan
Member
Hi, I am currently working on my top down GTA 1 style game, and I have run into an issue. When the player is wanted by police, every 16 - 30 seconds, I want the dispatcher to announce the player's direction.
I made it so I can see variable values of every object in the game, and the Direction variable just stops updating when the player turns after a minute or so of playing. I have kept testing it and I haven't found any patterns to when it stops... any ideas? (This version of the game I'm working on is in GM 8.1, I have been having the issue in GMS 1 as well)(direction is capitalized to not confuse with the built in direction variable)
Thanks!
Code:
///Direction Update
///Wanted by police and driving a car
if(wanted == true and state == 1){
directionUpdateTimer -= 1;
if(directionUpdateTimer <= 0){
directionUpdate = true;
}else{
directionUpdate = false;
}
if(directionUpdate == true and directionUpdateTimer <= 0){
directionUpdate = false;
directionUpdateTimer = choose(irandom_range(500,800));
if(Direction == "north"){
sound_play(snd_suspectNorth);
}
if(Direction == "south"){
sound_play(snd_suspectSouth);
}
if(Direction == "east"){
sound_play(snd_suspectEast);
}
if(Direction == "west"){
sound_play(snd_suspectWest);
}
}
}
if(state == 1){
///Set direction variable for police dispatcher update announcment
if(driving.image_angle >= 315 ){
Direction = "east";
}
if(driving.image_angle <= 45 ){
Direction = "east";
}
if(driving.image_angle >= 46 and driving.image_angle <= 135){
Direction = "north";
}
if(driving.image_angle >= 136 and driving.image_angle <= 225){
Direction = "west";
}
if(driving.image_angle >= 226 and driving.image_angle <= 314){
Direction = "south";
}
}
Thanks!