Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Is there any way to do collisions?
- timo1os
-
Scratcher
100+ posts
Is there any way to do collisions?
So I need a collision for a Top 2D game which the camera is above the player, and i added obstacles I have really bad collision system which is really bad is there is any way to improve the collision?
my collision:
my collision:
if <touching [ obstacles] ?> then
go to x: (OLD X) y: (OLD Y)
else
set [OLD X] to (x position)
set [OLD Y] to (y position)
end
- -Kryptonite-
-
Scratcher
1000+ posts
Is there any way to do collisions?
Well for RPG games
when green flag clicked
forever
if <some key pressed> then
point in direction (some direction v)
move (some) steps
if <touching [some sprite v] ?> then
move (negative some) steps
end
end
end
- timo1os
-
Scratcher
100+ posts
Is there any way to do collisions?
Well for RPG gamesbut as since i press w then s it starts glitchingwhen green flag clicked
forever
if <some key pressed> then
point in direction (some direction v)
move (some) steps
if <touching [some sprite v] ?> then
move (negative some) steps
end
end
end
and i use WASD controls
Last edited by timo1os (June 1, 2021 21:42:33)
- TheAnomalousPseudo
-
Scratcher
1000+ posts
Is there any way to do collisions?
Rather than pointing and moving, use the “change x/y” blocks. Also, you need to put the movement script into a condition:
forever
if <key [w v] pressed?> then
if <not <touching [obstacle v] ?>> then
change y by (5)
if <touching [obstacle v] ?> then
change y by (-6) //which allows you to not get stuck
end
end
end
end
- -Kryptonite-
-
Scratcher
1000+ posts
Is there any way to do collisions?
Well for RPG gamesbut as since i press w then s it starts glitchingwhen green flag clicked
forever
if <some key pressed> then
point in direction (some direction v)
move (some) steps
if <touching [some sprite v] ?> then
move (negative some) steps
end
end
end
and i use WASD controls
Huh works perfectly for me, and yeah WASD or any types of controls work for this…
- timo1os
-
Scratcher
100+ posts
Is there any way to do collisions?
Rather than pointing and moving, use the “change x/y” blocks. Also, you need to put the movement script into a condition:yeah but it doesnt work smoothly it jumpes off not collidesforever
if <key [w v] pressed?> then
if <not <touching [obstacle v] ?>> then
change y by (5)
if <touching [obstacle v] ?> then
change y by (-6) //which allows you to not get stuck
end
end
end
end
- MasterofTheBrick
-
Scratcher
1000+ posts
Is there any way to do collisions?
Use a custom block with no refresh to change the y position,
Last edited by MasterofTheBrick (June 2, 2021 09:11:37)
- timo1os
-
Scratcher
100+ posts
Is there any way to do collisions?
i dont really understand how to make it cause i dont really understand at which direction it should point?Well for RPG gamesbut as since i press w then s it starts glitchingwhen green flag clicked
forever
if <some key pressed> then
point in direction (some direction v)
move (some) steps
if <touching [some sprite v] ?> then
move (negative some) steps
end
end
end
and i use WASD controls
Huh works perfectly for me, and yeah WASD or any types of controls work for this…
- Discussion Forums
- » Help with Scripts
-
» Is there any way to do collisions?