S
Swegm
Guest
Hi!
I have a problem wich i have solved before but cant remember how i did that.
Problem is my unit goes gathering resources
when he will go back to his house delivering the resources
he just runs around and can't find the way back. (He also seems to double the speed)
my code looks like this
var goto_res
goto_res = instance_nearest(x,y,obj_resource)
var goto_house
goto_house = instance_nearest(x,y,obj_house)
while obj_house goto_tree = true && carry = 0
{
mp_potential_step(goto_res.x,goto_res.y,movespeed,true)
}
// resource gather
if place_meeting(x+2,y+2,obj_resource) && carry = 0
{
carry = carryMax
}
if carry = carryMax
{
mp_potential_step(goto_house.x,goto_house.y,movespeed,true)
}
if place_meeting(x+2,y+2,obj_house) && carry = carryMax
{
carry = 0
}
I have a problem wich i have solved before but cant remember how i did that.
Problem is my unit goes gathering resources
when he will go back to his house delivering the resources
he just runs around and can't find the way back. (He also seems to double the speed)
my code looks like this
var goto_res
goto_res = instance_nearest(x,y,obj_resource)
var goto_house
goto_house = instance_nearest(x,y,obj_house)
while obj_house goto_tree = true && carry = 0
{
mp_potential_step(goto_res.x,goto_res.y,movespeed,true)
}
// resource gather
if place_meeting(x+2,y+2,obj_resource) && carry = 0
{
carry = carryMax
}
if carry = carryMax
{
mp_potential_step(goto_house.x,goto_house.y,movespeed,true)
}
if place_meeting(x+2,y+2,obj_house) && carry = carryMax
{
carry = 0
}
Last edited by a moderator: