Discuss Scratch

pizzaguyyyyyyy
Scratcher
2 posts

shooting in the direction the player is facing

hi i'm making a 2D wave shooter game and i'm trying to make the bullet go where the player is facing and make it rapid fire. i tried almost every thing and i don't know what else i need to try. can i have some help. it also needs to be able to work while it is moving

Last edited by pizzaguyyyyyyy (March 25, 2024 14:08:07)

Cat_behind_Laptop
New to Scratch
10 posts

shooting in the direction the player is facing

Hello! You need to first create a bullet sprite
and draw the bullet itself. then we add these
two blocks of code to this sprite:

when green flag clicked
hide
forever
point in direction (player v)
if <mouse down?> then
create clone of [myself v]
wait (0.1) secs
end
end
when I start as a clone
show
repeat until <<touching [edge v] ?> or <touching [enemy v]>>
move (10) steps
end
delete this clone
  • time and bullet speed can be changed
Cat_behind_Laptop
New to Scratch
10 posts

shooting in the direction the player is facing

oh, I forgot, I need to update the block:
when green flag clicked
hide
forever
go to [player v]
point towards [player v]
if <mouse down?> then
create clone of [myself v]
wait (0.1) secs
end
end
  • I might make a mistake somewhere with a block or script
Cat_behind_Laptop
New to Scratch
10 posts

shooting in the direction the player is facing

  • (I recommend making a copy of the game before every major change to the game)
deck26
Scratcher
1000+ posts

shooting in the direction the player is facing

If you mean point in the direction the player is facing that's not what the above code does - it points towards the player and ignores the direction they are facing. What you want is

point in direction ([direction v] of [player v])
pizzaguyyyyyyy
Scratcher
2 posts

shooting in the direction the player is facing

thank you for the help. its works now and i can finish it

Powered by DjangoBB