Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do I get my sprite to sense another sprite?
- JoyBoy77777
-
6 posts
How do I get my sprite to sense another sprite?
Hi folks,
New scratcher here, looking for some help. I've been trying to make a very simple “open world” style game as my first project. One where a character (sprite 1) looks like they're moving around but stays in the center and the background (sprite 2) is what is actually moving around. Now my background is a large map with 2 colors, beige and green. I want to make it so that sprite 1 can only move in the beige area where it begins and not be able to access the green. Any advice on how to implement this?
New scratcher here, looking for some help. I've been trying to make a very simple “open world” style game as my first project. One where a character (sprite 1) looks like they're moving around but stays in the center and the background (sprite 2) is what is actually moving around. Now my background is a large map with 2 colors, beige and green. I want to make it so that sprite 1 can only move in the beige area where it begins and not be able to access the green. Any advice on how to implement this?
- Koamodo975
-
1000+ posts
How do I get my sprite to sense another sprite?
You could use the Scratch Prime movement & collision system:
Edit the numbers accordingly, just make sure that both move blocks are the same, except for being opposites. Do the same thing with the other keys.
- JoyBoy77777
-
6 posts
How do I get my sprite to sense another sprite?
Hey thanks for the help! However, I don't think this works. You see Sprite 2 (my background in this case) is constantly in contact with Sprite 1 (the main character on the centre). I need the backwards movement only to apply when Sprite 1 touches a specific colour on Sprite 2.
Here's some of my code for Sprite 2:
The first colour is the colour in Sprite 2 (background) that I want to be inaccessible and the second colour is the colour of Sprite 1 (the main character). I have tried switching these colours around and have received the same result.
Then here's how I implement this:
The result is that Sprite 1 is able to easily seem to walk into inaccessible areas when moving left. Whether or not the following code is in the function “Left” seems to make no difference:
Any ideas what I am doing wrong?
Here's some of my code for Sprite 2:
The first colour is the colour in Sprite 2 (background) that I want to be inaccessible and the second colour is the colour of Sprite 1 (the main character). I have tried switching these colours around and have received the same result.
Then here's how I implement this:
The result is that Sprite 1 is able to easily seem to walk into inaccessible areas when moving left. Whether or not the following code is in the function “Left” seems to make no difference:
Any ideas what I am doing wrong?
Last edited by JoyBoy77777 (July 16, 2024 20:00:08)
- Discussion Forums
- » Help with Scripts
-
» How do I get my sprite to sense another sprite?