Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How can you make it so a sprite can't touch another sprite?
- TheOfficialDerpCo
-
14 posts
How can you make it so a sprite can't touch another sprite?
We're making a platformer, and we're trying to make it so the sprite can't go through other sprites. We've found a way, though sometimes it glitches.
It goes like this:
Halp!
It goes like this:
when I receive
Halp!
- lederniersamourai
-
500+ posts
How can you make it so a sprite can't touch another sprite?
Sometimes, when you step 8 units, sprites can touch each other.
So you have to test after the move and go back until not touching. When you go back, try to do it with smaller steps, but in any case try to be exactly at the initial place.
So you have to test after the move and go back until not touching. When you go back, try to do it with smaller steps, but in any case try to be exactly at the initial place.
- TheOfficialDerpCo
-
14 posts
How can you make it so a sprite can't touch another sprite?
Very interesting… Thanks for the thought.
- gtoal
-
1000+ posts
How can you make it so a sprite can't touch another sprite?
There are two sprite-based ways to do this.
1) just move - if it touches, move back before the screen updates.
2) create an invisible sprite that is like the actual sprite but with an <n>-pixel wide boundary added to it. Then move until the boundary sprite touches the target. As long as your moves are not so large that the actual sprite can touch the target in a single move (ie < n), it should alert you before they actually collide.
1) just move - if it touches, move back before the screen updates.
2) create an invisible sprite that is like the actual sprite but with an <n>-pixel wide boundary added to it. Then move until the boundary sprite touches the target. As long as your moves are not so large that the actual sprite can touch the target in a single move (ie < n), it should alert you before they actually collide.
- TheOfficialDerpCo
-
14 posts
How can you make it so a sprite can't touch another sprite?
THANK YOU SO MUCH! THAT WORKS SO MUCH BETTER!
- DamoDog
-
38 posts
How can you make it so a sprite can't touch another sprite?
How would you move it back before a screen updates? i.e. a script example? There are two sprite-based ways to do this.
1) just move - if it touches, move back before the screen updates.
2) create an invisible sprite that is like the actual sprite but with an <n>-pixel wide boundary added to it. Then move until the boundary sprite touches the target. As long as your moves are not so large that the actual sprite can touch the target in a single move (ie < n), it should alert you before they actually collide.
- HOMELESSpotato08
-
22 posts
How can you make it so a sprite can't touch another sprite?
im stuck
- lillywill
-
2 posts
How can you make it so a sprite can't touch another sprite?
how do you make a sprite that can touch another sprite but not go through it. im trying to make a game put when the person moves around it keeps going through walls and stuff.
- Fischer57
-
100+ posts
How can you make it so a sprite can't touch another sprite?
how do you make a sprite that can touch another sprite but not go through it. im trying to make a game put when the person moves around it keeps going through walls and stuff.
Guys lease make another forum about this. This is Necroposting. im stuck
- Fischer57
-
100+ posts
How can you make it so a sprite can't touch another sprite?
Please don't necropost
- 0nonimus_Goomber2
-
4 posts
How can you make it so a sprite can't touch another sprite?
Step 1: When Green Flag Clicked Block.
Step 2: Set Default position.
Step 3: Do A Forever Block.
Step 4: Do an If _____ Then Block.
Step 5: Change X and Y to 5 and 5 then -5 and -5
Step 2: Set Default position.
Step 3: Do A Forever Block.
Step 4: Do an If _____ Then Block.
Step 5: Change X and Y to 5 and 5 then -5 and -5
- 0nonimus_Goomber2
-
4 posts
How can you make it so a sprite can't touch another sprite?
Step 1: When Green Flag Clicked Block.
Step 2: Set Default position.
Step 3: Do A Forever Block.
Step 4: Do an If _____ Then Block.
Step 5: Change X and Y to 5 and 5 then -5 and -5
Step 2: Set Default position.
Step 3: Do A Forever Block.
Step 4: Do an If _____ Then Block.
Step 5: Change X and Y to 5 and 5 then -5 and -5
- theanonymousweirdo
-
500+ posts
How can you make it so a sprite can't touch another sprite?
Step 1: When Green Flag Clicked Block.
Step 2: Set Default position.
Step 3: Do A Forever Block.
Step 4: Do an If _____ Then Block.
Step 5: Change X and Y to 5 and 5 then -5 and -5
Please check the date that the topic was originally posted before posting. This topic was made in 2016
Last edited by theanonymousweirdo (Oct. 22, 2020 00:36:08)
- FLORAIDER
-
5 posts
How can you make it so a sprite can't touch another sprite?
Last edited by FLORAIDER (Nov. 17, 2020 03:24:48)
- mysterious-neutron
-
1000+ posts
How can you make it so a sprite can't touch another sprite?
Please don't necropost
- Bannervessel6
-
1 post
How can you make it so a sprite can't touch another sprite?
Hey! uh, I'm trying to make it so that one of my sprites and stand on another sprite the “ground” sprite, this is not the actual ground sprite that I have, just a different one, but how do I make it so that it can go on top of it?
- goldenlion06
-
500+ posts
How can you make it so a sprite can't touch another sprite?
end
Last edited by goldenlion06 (Feb. 6, 2021 17:19:18)
- goldenlion06
-
500+ posts
How can you make it so a sprite can't touch another sprite?
change the “if touching floor to wall and set the change y by to change x by” to make it for walls
- goldenlion06
-
500+ posts
How can you make it so a sprite can't touch another sprite?
bro what if the wall isnt 15 pixels long? thas why you look at my comment and see that it changes x/y by 1 or -1 repeatedly without the any changes on screen so it stops exactly at the wall and doesnt even seem like you went through wall
- Discussion Forums
- » Help with Scripts
-
» How can you make it so a sprite can't touch another sprite?