Sawyer
Member
Hello everyone,
I try to make a building system.
I can put many differents building in my room. And i want than my units goes to build them.
For exemple if i put a wall on the map, and if an unit is near, it goes to build this wall. After less or more time it end to build it.
Actually if i put my wall my units goes to this wall, change his alpha instantanly and stay.
In my object player step event :
In my obj_road :
Create event
Step event :
draw event :
I try to make a building system.
I can put many differents building in my room. And i want than my units goes to build them.
For exemple if i put a wall on the map, and if an unit is near, it goes to build this wall. After less or more time it end to build it.
Actually if i put my wall my units goes to this wall, change his alpha instantanly and stay.
In my object player step event :
Code:
var can_build = 0;
with obj_in_contruction_parent
{
if hp_build = hp_max_build
{can_build = 0}
if hp_build < hp_max_build
{can_build = 1}}
nearest = instance_nearest(x,y,obj_in_contruction_parent)
if (selected = false && distance_to_object (obj_in_contruction_parent) <= 600 && can_build = 1 )
{
if (mp_grid_path(global.grid,path,x,y,nearest.x-1,nearest.y,1))
{path_start(path,speed_unit,path_action_stop,false);
}}
In my obj_road :
Create event
Code:
hp_build = 0
hp_max_build = 100
Code:
if (distance_to_object (obj_player) <= 10 )
{
hp_build +=1 //This is to have a counter to build
}
if hp_build = 100
{mp_grid_add_instances(global.grid, self, false);} //add my object to the grid
Code:
image_alpha=0.5 + 1*hp_build
draw_self()