Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to differentiate NPCs when they're in one sprite and one rendering
- obbko
- New to Scratch
1 post
How to differentiate NPCs when they're in one sprite and one rendering
I'm using a single sprite for my game but It's gonna have a ton of NPCs, I was wondering if anyone could help figure out a way for the game to tell what NPC is what when they're are multiple of them in on the screen at once
I have a decent detection script that can tell if the player is near enough to an NPC without the need for sensing sprites which I am gonna use for dialogue
(It has a y cord sensor as well but I am too lazy to put that in, it's just connected by an “and” operator
Any way to tell the program which NPC it's talking to?
I have a decent detection script that can tell if the player is near enough to an NPC without the need for sensing sprites which I am gonna use for dialogue
(It has a y cord sensor as well but I am too lazy to put that in, it's just connected by an “and” operator
Any way to tell the program which NPC it's talking to?
if <<<(x position) > ((X of NPC) + (100))> or <(x position) = ((X of NPC) - (100))>> then
broadcast [ dialogue]
Last edited by obbko (May 13, 2024 07:50:37)
- whitlow72
- Scratcher
34 posts
How to differentiate NPCs when they're in one sprite and one rendering
Make a sprite only variable that represents the ID of the NPC. Then replace the
(If NPC clones are deleted, you'll need a separate way to store the ID)
broadcast [dialogue v]with
broadcast (ID)You'll need a bunch of broadcasts that are just a number however.
(If NPC clones are deleted, you'll need a separate way to store the ID)
Last edited by whitlow72 (May 13, 2024 14:48:07)
I love scratch
and Rain World
Might try helping out with code sometimes.
Play my WIP strategy game, Islands!
- Discussion Forums
- » Help with Scripts
- » How to differentiate NPCs when they're in one sprite and one rendering