Player Cooldown

2 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$49.99
List Price:  $69.99
You save:  $20
€46.38
List Price:  €64.93
You save:  €18.55
£39.89
List Price:  £55.85
You save:  £15.96
CA$68.39
List Price:  CA$95.75
You save:  CA$27.36
A$75.62
List Price:  A$105.88
You save:  A$30.25
S$67.65
List Price:  S$94.72
You save:  S$27.06
HK$390.63
List Price:  HK$546.91
You save:  HK$156.28
CHF 45.32
List Price:  CHF 63.46
You save:  CHF 18.13
NOK kr540.83
List Price:  NOK kr757.20
You save:  NOK kr216.37
DKK kr346.01
List Price:  DKK kr484.44
You save:  DKK kr138.43
NZ$83.08
List Price:  NZ$116.32
You save:  NZ$33.23
د.إ183.61
List Price:  د.إ257.06
You save:  د.إ73.45
৳5,489.47
List Price:  ৳7,685.71
You save:  ৳2,196.23
₹4,174.70
List Price:  ₹5,844.92
You save:  ₹1,670.21
RM236.90
List Price:  RM331.68
You save:  RM94.78
₦70,962.30
List Price:  ₦99,352.90
You save:  ₦28,390.60
₨13,872.15
List Price:  ₨19,422.12
You save:  ₨5,549.97
฿1,835.14
List Price:  ฿2,569.35
You save:  ฿734.20
₺1,612.71
List Price:  ₺2,257.93
You save:  ₺645.21
B$257.06
List Price:  B$359.91
You save:  B$102.84
R919.21
List Price:  R1,286.96
You save:  R367.75
Лв90.71
List Price:  Лв127.01
You save:  Лв36.29
₩68,279.30
List Price:  ₩95,596.49
You save:  ₩27,317.18
₪186.20
List Price:  ₪260.69
You save:  ₪74.49
₱2,872.25
List Price:  ₱4,021.38
You save:  ₱1,149.12
¥7,785.79
List Price:  ¥10,900.73
You save:  ¥3,114.94
MX$837.71
List Price:  MX$1,172.87
You save:  MX$335.15
QR181.98
List Price:  QR254.79
You save:  QR72.81
P681.01
List Price:  P953.47
You save:  P272.46
KSh6,621.46
List Price:  KSh9,270.57
You save:  KSh2,649.11
E£2,369.41
List Price:  E£3,317.36
You save:  E£947.95
ብር2,858.54
List Price:  ብር4,002.19
You save:  ብር1,143.64
Kz41,809.30
List Price:  Kz58,536.37
You save:  Kz16,727.06
CLP$46,240.75
List Price:  CLP$64,740.75
You save:  CLP$18,500
CN¥361.16
List Price:  CN¥505.65
You save:  CN¥144.49
RD$2,895.12
List Price:  RD$4,053.41
You save:  RD$1,158.28
DA6,726.94
List Price:  DA9,418.25
You save:  DA2,691.31
FJ$113.51
List Price:  FJ$158.92
You save:  FJ$45.41
Q388.49
List Price:  Q543.91
You save:  Q155.42
GY$10,421.54
List Price:  GY$14,591
You save:  GY$4,169.45
ISK kr6,972.10
List Price:  ISK kr9,761.50
You save:  ISK kr2,789.40
DH500.60
List Price:  DH700.89
You save:  DH200.28
L887.29
List Price:  L1,242.28
You save:  L354.98
ден2,857.41
List Price:  ден4,000.60
You save:  ден1,143.19
MOP$400.79
List Price:  MOP$561.14
You save:  MOP$160.35
N$921.79
List Price:  N$1,290.58
You save:  N$368.79
C$1,832.69
List Price:  C$2,565.92
You save:  C$733.22
रु6,654.99
List Price:  रु9,317.52
You save:  रु2,662.52
S/185.34
List Price:  S/259.50
You save:  S/74.15
K193.05
List Price:  K270.29
You save:  K77.23
SAR187.48
List Price:  SAR262.49
You save:  SAR75.01
ZK1,362.81
List Price:  ZK1,908.05
You save:  ZK545.23
L230.78
List Price:  L323.12
You save:  L92.33
Kč1,156.66
List Price:  Kč1,619.42
You save:  Kč462.75
Ft17,987.75
List Price:  Ft25,184.29
You save:  Ft7,196.54
SEK kr541.71
List Price:  SEK kr758.43
You save:  SEK kr216.72
ARS$44,114.95
List Price:  ARS$61,764.46
You save:  ARS$17,649.51
Bs345.50
List Price:  Bs483.72
You save:  Bs138.22
COP$194,137.21
List Price:  COP$271,807.63
You save:  COP$77,670.42
₡25,482.48
List Price:  ₡35,677.52
You save:  ₡10,195.03
L1,227.34
List Price:  L1,718.38
You save:  L491.03
₲374,060
List Price:  ₲523,713.94
You save:  ₲149,653.93
$U1,921.90
List Price:  $U2,690.81
You save:  $U768.91
zł199.36
List Price:  zł279.12
You save:  zł79.76
Already have an account? Log In

Transcript

Hey there, in this lecture we're going to implement a player cooldown. Basically, if an enemy's bullet hits the player, we want the player to become transparent for one second. While the player is transparent, the enemies can't attack it, and then after one second, the player should return back to normal. This will be done using a cooldown variable. At the beginning it will be at zero. When a bullet hits a player, it will check whether the player's cooldown variable is zero.

If it is, then the players HP is reduced and the cooldown variable is set to 60. That will also make the player transparent. So whenever a bullet hits a player, it will see that the cooldown is not at zero and so it will not hit the player. Now he stepped the cooldown value goes down by one so when the cooldown value reaches zero, the police will be able to hit the player again. So now let's get to it. First of all, open our player and go to its create event.

I click on the plus button here and name this new variable cooldown. Its value will be zero. Now I'll add the CEP event. First of all add any viable condition here. This condition will check whether the cooldown variable is greater than zero, that means that the player has been heard. So I'll add an assign variable action and attach it to this condition, the variable will be cooldown and the value will be minus one relative.

So if the cooldown value is greater than zero, it will go down by one. Now I'll search alpha here and add the circumstance alpha action under the same condition. This has the alpha or opacity of the instance. So at one it's fully visible at zero, it's completely invisible and 0.5, it's transparent. You can also use any value between zero and one for the alpha. So I'll set the alpha to 0.5 to make it transparent, and now insert and add an else block.

Any actions attached to the s log only run if the previous condition is false, which means that the cooldown is not greater than zero. So in that case, I want to reset the stances transparency, so I'll add the alpha action here. Attack Two L's and 32 one. Now I'll open overlap enemy, I'll open the open a collision event. I'll add the variable action here and attach all actions to it. Now here we want to check whether the player's cooldown value is zero.

So first of all, I click on this arrow and apply this action to other because the other objects here is a player. So the variable will be cooled down and the condition will be equal to zero. So if the player's cooldown value is zero, only, then we'll attach p go down. Now we'll click on the plus button here, and set cooldown to 60. Since this action is already applied to the other instance, it was had a player schooled on variable to succeed. So now the player can be hit for one second, and now run the game.

Now you can see the players one second cooldown in action. Now let's move on to the next lecture we will learn about loops

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.