woods
Member
been at this for a couple days...
working on an olskool battletech inspired, time/turn based, squad tactics game.
i have a hex grid map and am trying to get my mech to move around properly..
60^ turns, walk front/back no problem..
what i am trying to do is get the mech to walk to the nearest hex in front of him and stop(effectively snapping to the center of the new hex)
i have a target hex "following the player" in front
step event:
i want to use this to target the nearest front facing hex when i move my player..
player step event:
with the else speed = 0 at the end of the code, my mech moves just a notch and stops
(i commented out the else speed=0 )
my mech will walk forward but wont stop
what i think is happening is the target "hx,hy" is changing as i move out of my current hex(i want to move 1 hex forward on keypress)
end game result is going to be multiple mechs with move and shoot on two initiative timers... (if skillcheck is passed, then move)
sidenote:
am i coming at this project completely backwards?
working on an olskool battletech inspired, time/turn based, squad tactics game.
i have a hex grid map and am trying to get my mech to move around properly..
60^ turns, walk front/back no problem..
what i am trying to do is get the mech to walk to the nearest hex in front of him and stop(effectively snapping to the center of the new hex)
i have a target hex "following the player" in front
step event:
GML:
x=obj_mech_1.x+lengthdir_x(64,obj_mech_1.direction);
y=obj_mech_1.y+lengthdir_y(64,obj_mech_1.direction);
player step event:
Code:
/// movement
//facing
if direction = 0{sprite_index = spr_mech_1_east;}
if direction = 60{sprite_index = spr_mech_1_north_east;}
if direction = 120{sprite_index = spr_mech_1_north_west;}
if direction = 180{sprite_index = spr_mech_1_west;}
if direction = 240{sprite_index = spr_mech_1_south_west;}
if direction = 300{sprite_index = spr_mech_1_south_east;}
if direction = 360{direction = 0;}
//rotate left and right
if keyboard_check_pressed(vk_left) {direction += 60;}
if keyboard_check_pressed(vk_right) {direction -= 60;}
var hx = instance_nearest(obj_hex_target.x,obj_hex_target.y, obj_hex_parent).x; //want hex in front of mech, not nearest
var hy = instance_nearest(obj_hex_target.x,obj_hex_target.y, obj_hex_parent).y; // target_hex? and point_direction? length_dir?
if keyboard_check_pressed(ord("W"))
{
move_towards_point(hx,hy,1);// want to move to next hex in front of mech
image_speed = 0.25;
}
/*
else
{
image_speed = 0;
speed = 0;
}
(i commented out the else speed=0 )
my mech will walk forward but wont stop
what i think is happening is the target "hx,hy" is changing as i move out of my current hex(i want to move 1 hex forward on keypress)
end game result is going to be multiple mechs with move and shoot on two initiative timers... (if skillcheck is passed, then move)
sidenote:
am i coming at this project completely backwards?
Last edited by a moderator: