NEED HELP

id: 751775

category: Help with Scripts

posts: 17

I have been working on a game recently and I came across an issue that I have no idea how to solve. its a top down scroller and in the game, you can pick up items by clicking on them. the problem is that when two items are directly Infront of each other, they both get picked up. I only want the player to pick up one object at a time. I cant figure it out and if someone could please tell me a script to solve this it would be greatly appreciated! btw all the items are clones.

bruh-moment6 wrote:

I have been working on a game recently and I came across an issue that I have no idea how to solve. its a top down scroller and in the game, you can pick up items by clicking on them. the problem is that when two items are directly Infront of each other, they both get picked up. I only want the player to pick up one object at a time. I cant figure it out and if someone could please tell me a script to solve this it would be greatly appreciated!
you're picking up by clicking them?

invalidaccess wrote:

bruh-moment6 wrote:

I have been working on a game recently and I came across an issue that I have no idea how to solve. its a top down scroller and in the game, you can pick up items by clicking on them. the problem is that when two items are directly Infront of each other, they both get picked up. I only want the player to pick up one object at a time. I cant figure it out and if someone could please tell me a script to solve this it would be greatly appreciated!
you're picking up by clicking them?
yeah
I think I'm just gonna give up on the game and trash it.
RokCoder RokCoder loading

bruh-moment6 wrote:

I think I'm just gonna give up on the game and trash it.
Giving up so easily doesn't bode well for future tasks.

Share the project and I'm sure you'll get lots of simple solutions. I'm sure you can handle this with something along the lines of setting a pickUp variable to false at the beginning of each frame, setting it to true when something has been picked up and checking that it's false before allowing anything to be picked up.
han614698 han614698 loading

RokCoder wrote:

bruh-moment6 wrote:

I think I'm just gonna give up on the game and trash it.
Giving up so easily doesn't bode well for future tasks.

Share the project and I'm sure you'll get lots of simple solutions. I'm sure you can handle this with something along the lines of setting a pickUp variable to false at the beginning of each frame, setting it to true when something has been picked up and checking that it's false before allowing anything to be picked up.
Theoretically if they're using the ‘when sprite clicked’ hat block then that wouldn't work because the code would be running at the exact same frame.
RokCoder RokCoder loading

han614698 wrote:

RokCoder wrote:

bruh-moment6 wrote:

I think I'm just gonna give up on the game and trash it.
Giving up so easily doesn't bode well for future tasks.

Share the project and I'm sure you'll get lots of simple solutions. I'm sure you can handle this with something along the lines of setting a pickUp variable to false at the beginning of each frame, setting it to true when something has been picked up and checking that it's false before allowing anything to be picked up.
Theoretically if they're using the ‘when sprite clicked’ hat block then that wouldn't work because the code would be running at the exact same frame.
If they were using the click events then they wouldn't be having the problem - only the top sprite would be responding to the event…
the sprites that I am trying to pick up are clones of the same sprite. its also not a dragging system. I click on the object, and it teleports into my hand. also, I'm using a script that says <if touching mouse, wait until mouse down>
RokCoder RokCoder loading

bruh-moment6 wrote:

the sprites that I am trying to pick up are clones of the same sprite. its also not a dragging system. I click on the object, and it teleports into my hand. also, I'm using a script that says <if touching mouse, wait until mouse down>
The method I suggested will work for this. You're not going to get anything more specific unless you share the project.

RokCoder wrote:

bruh-moment6 wrote:

the sprites that I am trying to pick up are clones of the same sprite. its also not a dragging system. I click on the object, and it teleports into my hand. also, I'm using a script that says <if touching mouse, wait until mouse down>
The method I suggested will work for this. You're not going to get anything more specific unless you share the project.
k I will share it: https://scratch.mit.edu/projects/993013454
holy * I solved it
RokCoder RokCoder loading

bruh-moment6 wrote:

I SOLVED IT
Looks like you solved it using advice given in this thread. Well done
i need help making a sonic game
deck26 deck26 loading

SUPERSONIC_racing wrote:

i need help making a sonic game
You need help learning to create your own new topic instead of posting on someone else's topic. Look for the New Topic button.

deck26 wrote:

SUPERSONIC_racing wrote:

i need help making a sonic game
You need help learning to create your own new topic instead of posting on someone else's topic. Look for the New Topic button.
thx for advice!