• 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!

GML all trees loses value RTS game

S

Swegm

Guest
Hi there people !

Im creating an rts style game, and want the tree that collides with woodworker to lose value with 0.1
it kinda works the problem is that all trees on the map loses value. Dunno how to handle this by my own i think .. thanks in advance

Andreas

STEP EVENT in obj_Woodcutter
Code:
if place_meeting(x,y,obj_tree) && state = 'collect'
{
with (obj_tree)
tree -= 0.1
}
 

JackTurbo

Member
Youre checking for a collision with all trees and then modifying all trees.

Use instance_place to check for collision. Store what it returns in a local variable. This will be noone if there is no collision or the trees instance id.

If it doesn't equal noone modify that instances variables.

Frostycat has a good write up on the differences between objects and instances that might be useful further reading in the tutorial section.
 
S

Swegm

Guest
Youre checking for a collision with all trees and then modifying all trees.

Use instance_place to check for collision. Store what it returns in a local variable. This will be noone if there is no collision or the trees instance id.

If it doesn't equal noone modify that instances variables.

Frostycat has a good write up on the differences between objects and instances that might be useful further reading in the tutorial section.

Oh thanks ! i will try it out, hope i can solve it by this info :)
 
Top