Discuss Scratch

Megalonaut
Scratcher
10 posts

HOW TO DO COLLISIONS ON MY GAME???

Ok, so, basically, I'm working on a top-down game, and right now, I don't really know what it is about, I'm just testing until I do the movement just right then focus on the other parts of the game. My whole movement system is kinda complicated, since it's a scrolling top-down, the fact that the strafing was replaced by a rotation of the character's head, which is really cool, but also complicates it even more. The only problem I have though, is not a tiny one, as I have 0 idea on how to make the wall collisions and stop the player or an object like the box from just ignoring the wall. PLEASE HELP!
https://scratch.mit.edu/projects/889673361/
this is the game btw, only shared it to get help
Megalonaut
Scratcher
10 posts

HOW TO DO COLLISIONS ON MY GAME???

btw if u guys cant tell the grey thing is supposed to be walls
qwertycodechamp90411
Scratcher
100+ posts

HOW TO DO COLLISIONS ON MY GAME???

Easy method:

move5stepsiftouchingwall?thenmove-5steps

Hard Method:
definemovexstepswithwallcollisionchangexbyx*cosof90-directioniftouchingwall?thenchangexby0-x*cosof90-direction negativechangeybyx*sinof90-directioniftouchingwall?thenchangeyby0-x*sinof90-direction negative
Megalonaut
Scratcher
10 posts

HOW TO DO COLLISIONS ON MY GAME???

alright, thanks for answering! ill test that out right now!
Megalonaut
Scratcher
10 posts

HOW TO DO COLLISIONS ON MY GAME???

it kinda works, but if i just spin a little it breaks and i just phase thru the wall, I think you didn't check out the project, the wall collision needs to be compatible with the movement system, and this one is good but its for more straight-forward simple top-down games
Megalonaut
Scratcher
10 posts

HOW TO DO COLLISIONS ON MY GAME???

ok, i did the smart thing and made a hitbox, but now the problem is that whenever i touch the wall i cant escape and just get stuck there
Megalonaut
Scratcher
10 posts

HOW TO DO COLLISIONS ON MY GAME???

im thinking that if nobody finds a solution i might have to just not put in any walls in the game, maybe I can just use kill blocks that send the player to the start
Megalonaut
Scratcher
10 posts

HOW TO DO COLLISIONS ON MY GAME???

Thanks for the help! Even though it doesn't work in my current situation, I still appreciate it!

qwertycodechamp90411 wrote:

Easy method:

move5stepsiftouchingwall?thenmove-5steps

Hard Method:
definemovexstepswithwallcollisionchangexbyx*cosof90-directioniftouchingwall?thenchangexby0-x*cosof90-direction negativechangeybyx*sinof90-directioniftouchingwall?thenchangeyby0-x*sinof90-direction negativeend/quote

Last edited by Megalonaut (Sept. 6, 2023 15:09:52)

sashimiricedev
Scratcher
100+ posts

HOW TO DO COLLISIONS ON MY GAME???

I may have the solution to your problem. I have a studio dedicated to helping Scratchers with common problems. It's small for now, but I plan on adding more projects and demos to it.
Link to project: https://scratch.mit.edu/projects/891352927/
Link to studio: https://scratch.mit.edu/studios/33415081/
Hope this helps. Comment on the project or my profile if it doesnt.

Last edited by sashimiricedev (Sept. 11, 2023 21:17:00)

Cobman57
Scratcher
1 post

HOW TO DO COLLISIONS ON MY GAME???

thanks, the collisions work really well
sayThank you!
Coder_68815
Scratcher
7 posts

HOW TO DO COLLISIONS ON MY GAME???

define
samitha_4_A
Scratcher
3 posts

HOW TO DO COLLISIONS ON MY GAME???

Im making a Golf game end everytime I try to make collisions the ball ends up going inside the level can anyone write a piece of code for that?

Powered by DjangoBB