You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Assets/Scripts/Player.cs
+26-17Lines changed: 26 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,7 @@
1
1
usingUnityEngine;
2
2
3
3
/// <summary>
4
-
/// Handles the movement and shooting of the
5
-
/// player ship.
4
+
/// Handles the movement and shooting of the player ship.
6
5
/// </summary>
7
6
[RequireComponent(typeof(Rigidbody2D))]
8
7
[RequireComponent(typeof(BoxCollider2D))]
@@ -20,21 +19,33 @@ public class Player : MonoBehaviour
20
19
[Tooltip("How quickly the player is able to turn.")]
21
20
publicfloatrotationSpeed=0.1f;
22
21
22
+
/// <summary>
23
+
/// The amount of seconds it takes for the player to respawn after dying.
24
+
/// </summary>
25
+
[Tooltip("The amount of seconds it takes for the player to respawn after dying.")]
26
+
publicfloatrespawnDelay=3.0f;
27
+
28
+
/// <summary>
29
+
/// The amount of seconds the player has invulnerability after respawning.
30
+
/// This is to prevent the player from instantly dying if spawning into an
31
+
/// asteroid.
32
+
/// </summary>
33
+
[Tooltip("The amount of seconds the player has invulnerability after respawning. This is to prevent the player from instantly dying if spawning into an asteroid.")]
34
+
publicfloatrespawnInvulnerability=3.0f;
35
+
23
36
/// <summary>
24
37
/// The object that is cloned when creating a bullet.
25
38
/// </summary>
26
39
[Tooltip("The object that is cloned when creating a bullet.")]
27
40
publicBulletbulletPrefab;
28
41
29
42
/// <summary>
30
-
/// The current direction the player is turning.
31
-
/// 1=left, -1=right, 0=none
43
+
/// The current direction the player is turning. 1=left, -1=right, 0=none
32
44
/// </summary>
33
45
privatefloat_turnDirection=0.0f;
34
46
35
47
/// <summary>
36
-
/// Whether the ship's thrusts are activated causing
37
-
/// it to move forward.
48
+
/// Whether the ship's thrusts are activated causing it to move forward.
38
49
/// </summary>
39
50
privatebool_thrusting=false;
40
51
@@ -51,21 +62,20 @@ private void Awake()
51
62
52
63
privatevoidOnEnable()
53
64
{
54
-
// Turn off collisions for a few seconds after
55
-
// spawning to ensure the player has enough
56
-
// time to safely move away from asteroids
65
+
// Turn off collisions for a few seconds after spawning to ensure the
66
+
// player has enough time to safely move away from asteroids
0 commit comments