Discuss Scratch

menikin1
Scratcher
48 posts

how to make collisions with invisible walls

I am trying to get my sprite to stop going through my walls. It has to be invisible or else it looks weird. Thanks.
Uniquename1
Scratcher
100+ posts

how to make collisions with invisible walls

If touching sprite or color should both work even if ghost effect is set to 100.

Alternatively if the walls are on the border that the sprite can't go out of then

if <<key [right arrow] pressed?> and <(x position) < [200]>> then
change x by (10)
end

With this he will only move up to about 200, then if he's further over than that he won't move anymore to the right. Essentially like hitting a wall.
Pezd
Scratcher
100+ posts

how to make collisions with invisible walls

The trick is that the sensing block
<touching [sprite6 v] ?>
still works when ‘sprite6’ has the ghost effect turned all the way.
cs641311
Scratcher
100+ posts

how to make collisions with invisible walls

Try setting the color of the invisable walls to the color of the background that will make the wall seem invisable.
-Nostalgic-
Scratcher
6 posts

how to make collisions with invisible walls

menikin1 wrote:

I am trying to get my sprite to stop going through my walls. It has to be invisible or else it looks weird. Thanks.
Instead of using the hide block, use
set [ Ghostv] effect to (100)

menikin1
Scratcher
48 posts

how to make collisions with invisible walls

Pezd wrote:

The trick is that the sensing block
<touching [sprite6 v] ?>
still works when ‘sprite6’ has the ghost effect turned all the way.

How do I make it not go through though?
PhoenixDragonBlue
Scratcher
100+ posts

how to make collisions with invisible walls

Write this in the wall script :
when green flag clicked
set [ghost v] effect to (100)
and this in the object to be blocked by the wall's script:
when green flag clicked
forever
Touching wall? ::custom
end
define Touching wall?
if <touching [Wall v] ?> then
repeat until <not <touching [Wall v] ?>
change y by (-1)
You may have to replace
change y by (-1)
to
change y by (1)
depending on which side the wall is on.
Also, when making the
 Touching wall? ::custom
be sure to check the “Run Without Screen Refresh” box.
menikin1
Scratcher
48 posts

how to make collisions with invisible walls

PhoenixDragonBlue wrote:

Write this in the wall script :
when green flag clicked
set [ghost v] effect to (100)
and this in the object to be blocked by the wall's script:
when green flag clicked
forever
Touching wall? ::custom
end
define Touching wall?
if <touching [Wall v] ?> then
repeat until <not <touching [Wall v] ?>
change y by (-1)
You may have to replace
change y by (-1)
to
change y by (1)
depending on which side the wall is on.
Also, when making the
 Touching wall? ::custom
be sure to check the “Run Without Screen Refresh” box.

Thanks, this worked.
PhoenixDragonBlue
Scratcher
100+ posts

how to make collisions with invisible walls

menikin1 wrote:

PhoenixDragonBlue wrote:

-snip-

Thanks, this worked.
No problem

Powered by DjangoBB