• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM [SOLVED] Not targeting all

M

Mystic76

Guest
Straightforward problem.
In the game, you control a robot. You can place seeds on dirt tiles (they are always perfectly on the tile) and you can press spacebar to water the seeds to grow into a new plant. For some reason, only one plant gets spawned and you have to wait for the timer to end (yes i made a timer) for the plant to become visible and for the seeds to be destroyed. You cannot create another plant while another one is on the timer for some reason! You can also only water the plants in the order you placed the seeds. I'll post more details if asked, this post is rushed. Please explain what's wrong.

Code:
sprite_index=spr_dirt

if instance_exists(obj_waterseed) water=position_meeting(obj_waterseed.x,obj_waterseed.y,self)
if instance_exists(obj_earthseed) earth=position_meeting(obj_earthseed.x,obj_earthseed.y,self)

if position_meeting(obj_robo.x,obj_robo.y+32,self) {
if keyboard_check_pressed(vk_space) && global.inventoryup=false {
if earth && water {
instance_create(x+32,y+32,obj_mud)
}
}
sprite_index=spr_farmland
}
 
D

Danei

Guest
when you're setting the water and earth variables, you're checking the x and y of a specific obj_waterseed/obj_earthseed instance, i.e. the first one. You should check a position relative to this dirt instance, like water = position_meeting(x,y,obj_waterseed). That way it'll return true if it's meeting any obj_waterseed, not just if a certain one is meeting it.
 
M

Mystic76

Guest
when you're setting the water and earth variables, you're checking the x and y of a specific obj_waterseed/obj_earthseed instance, i.e. the first one. You should check a position relative to this dirt instance, like water = position_meeting(x,y,obj_waterseed). That way it'll return true if it's meeting any obj_waterseed, not just if a certain one is meeting it.
Thank you so much. You're a lifesaver!
 
Top