Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do I add a shoot cool down?
- among_yourself
- Scratcher
39 posts
How do I add a shoot cool down?
Im making a FPS and i wanna know how to add a cooldown for shots taken, Ive been trying to make it so guns have different fire rates like a sniper has a longer shoot cooldown while a assault rifle has a faster cooldown?
when meme seen
if <meme dead> then
say [that memes mid]
else
forever
repost
end
end
- SansStudios
- Scratcher
1000+ posts
How do I add a shoot cool down?
Hi, and welcome to the forums! It's a little hard to know exactly how your shooting works without a link to the project or some code. However, if you're using a clone-based system, you can use the wait block:
You can change your shoot script to be something like this:
This will make it so you can only shoot once per second.
wait (...) secs
You can change your shoot script to be something like this:
forever
if <key [space v] pressed?> then
create clone of [bullet v] // create a bullet
wait (1) secs // wait 1 second
end
end
This will make it so you can only shoot once per second.
☁️ scratchcloud ☁️
Click above to check it out! I've worked on it for over a year!
Just like sudden sadness comes hangin' on the breeze
- among_yourself
- Scratcher
39 posts
How do I add a shoot cool down?
Hi, and welcome to the forums! It's a little hard to know exactly how your shooting works without a link to the project or some code. However, if you're using a clone-based system, you can use the wait block:wait (...) secs
You can change your shoot script to be something like this:forever
if <key [space v] pressed?> then
create clone of [bullet v] // create a bullet
wait (1) secs // wait 1 second
end
end
This will make it so you can only shoot once per second.
Thats not really how mine works, heres a project link: https://scratch.mit.edu/projects/581256421/ so you can help me. I dont use cloning because im not thank advanced with it but its a good idea!
when meme seen
if <meme dead> then
say [that memes mid]
else
forever
repost
end
end
- givetoespls
- Scratcher
23 posts
How do I add a shoot cool down?
ok, i have something that might work.
now, add another script.
no problem.
when flag clicked
set [shoot.cooldown] to [0]
forever
if <(shoot.cooldown)=(0)> then
set [shoot.cooldown] to [1]
create clone of [bullet]
end
end
now, add another script.
when flag clicked
forever
if <(shoot.cooldown)=(1)> then
wait (.1) secs
set [shoot.cooldown] to [0]
end
end
no problem.
Follows would be appreciated!
When flag clicked
go to x: (0) y: (0)
set [Happy v] to (0)
hide
clear
pen up
when I receive [A Follow v]
set [Happy v] to (1)
Draw a Smile!
define Draw a Smile!
point in direction (90)
set pen color to [#000000]
set pen size to (6)
pen down
repeat (180)
turn ccw (1) degrees
move (1) steps
end
pen up
set pen size to (12)
change x by (-88)
change x by (-18)
change y by (35)
pen down
pen up
change x by (58)
pen down
pen up
change x by (-25)
change y by (-12)
point in direction (-165)
set pen size to (6)
pen down
move (40) steps
point in direction (90)
move (12) steps
- CODE_MINT
- Scratcher
8 posts
How do I add a shoot cool down?
gun sprite
bullet sprite
when green flag clicked
switch costume to [bullet v]
set [cooldown v] to [1]
set [oncooldown v] to [0]
forever
if <(shoot) = [1]> then
set [oncooldown v] to [1]
wait (cooldown) secs
set [oncooldown v] to [0]
end
end
bullet sprite
when green flag clicked
if <key [space v] pressed?> then
if <(oncooldown) = [0]> then
create clone of [myself v]
end
Last edited by CODE_MINT (Oct. 9, 2021 22:41:53)
- among_yourself
- Scratcher
39 posts
How do I add a shoot cool down?
Fixed issue my friend helped, dOnt post here anymore.
when meme seen
if <meme dead> then
say [that memes mid]
else
forever
repost
end
end
- Discussion Forums
- » Help with Scripts
- » How do I add a shoot cool down?