Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » NEED HELP
- bruh-moment6
- Scratcher
20 posts
NEED HELP
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.
Last edited by bruh-moment6 (April 1, 2024 20:21:00)
when green flag clicked
say [I have crippling depression]
- invalidaccess
- Scratcher
68 posts
NEED HELP
you're picking up by clicking them? 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!
- bruh-moment6
- Scratcher
20 posts
NEED HELP
yeahyou're picking up by clicking them? 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!
when green flag clicked
say [I have crippling depression]
- bruh-moment6
- Scratcher
20 posts
NEED HELP
I think I'm just gonna give up on the game and trash it.
when green flag clicked
say [I have crippling depression]
- RokCoder
- Scratcher
1000+ posts
NEED HELP
Giving up so easily doesn't bode well for future tasks. I think I'm just gonna give up on the game and trash it.
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
- Scratcher
1000+ posts
NEED HELP
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.Giving up so easily doesn't bode well for future tasks. I think I'm just gonna give up on the game and trash it.
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.
<Scratch Wikian | Forum Helper | 6000+ Posts>
Credit to -gge for the icons in my signature | I condensed all this code into five lines using [p] tags, idk why
- invalidaccess
- Scratcher
68 posts
NEED HELP
maybe this one helps
https://scratch.mit.edu/projects/993367485/
https://scratch.mit.edu/projects/993367485/
- RokCoder
- Scratcher
1000+ posts
NEED HELP
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…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.Giving up so easily doesn't bode well for future tasks. I think I'm just gonna give up on the game and trash it.
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.
- bruh-moment6
- Scratcher
20 posts
NEED HELP
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>
when green flag clicked
say [I have crippling depression]
- RokCoder
- Scratcher
1000+ posts
NEED HELP
The method I suggested will work for this. You're not going to get anything more specific unless you share the project. 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>
- bruh-moment6
- Scratcher
20 posts
NEED HELP
k I will share it: https://scratch.mit.edu/projects/993013454The method I suggested will work for this. You're not going to get anything more specific unless you share the project. 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>
when green flag clicked
say [I have crippling depression]
- bruh-moment6
- Scratcher
20 posts
NEED HELP
holy * I solved it
when green flag clicked
say [I have crippling depression]
- bruh-moment6
- Scratcher
20 posts
NEED HELP
I SOLVED IT
when green flag clicked
say [I have crippling depression]
- deck26
- Scratcher
1000+ posts
NEED HELP
You need help learning to create your own new topic instead of posting on someone else's topic. Look for the New Topic button. i need help making a sonic game
- SUPERSONIC_racing
- Scratcher
7 posts
NEED HELP
thx for advice!You need help learning to create your own new topic instead of posting on someone else's topic. Look for the New Topic button. i need help making a sonic game
- Discussion Forums
- » Help with Scripts
- » NEED HELP