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

Apples falling from trees

  • Thread starter Captain_ArrowWound
  • Start date
C

Captain_ArrowWound

Guest
In the game I am making the tree automatically creates 1 to 3 apples when the game starts. If the player walks by the tree and presses the space bar, I want the apples on the tree to fall from the tree to the ground. I don't know how to get it only effect the apples that are on the one tree that is by the player. Right now, if the player goes up to a tree and presses the space bar, all the apples on any tree will fall down. I am not sure how to set it up so that the apples fall from just the one tree. So do you have any ideas for how I can set this up? Thanks for the help!
 

NightFrost

Member
Check distance to player with point_distance and make sure it is close enough. Set sprite origins in manner that makes sense in this context, as those are the points used when going by default x, y values in the measurement.
 

Alexx

Member
Sounds like your using the object name, such as obect_apple.
You should be using the id of just one of the apples.
There are a few ways to this, but in this case I would check the player is near an apple, and then get the id of nearest one, and make just that one fall.
 
C

Captain_ArrowWound

Guest
Thanks! I did that and now it works great. But, how would I make it so that when the player picks up an apple with the space bar. One of the apples that is close to the player will be destroyed. Right now, with my code, all the apples are destroyed when the player picks up an apple.
 
Top