FCV Engine
0.1
A tool and framework for tutorials in game development
Loading...
Searching...
No Matches
fallDetectorScript.cs
1
using
System;
2
using
UnityEngine;
3
using
UnityEngine.SceneManagement;
7
public
class
FallDetectorScript
: MonoBehaviour
8
{
9
private
Transform playerTransform;
10
11
private
void
Start()
12
{
13
playerTransform =
Movement
.PlayerTransform;
14
}
15
19
void
Update
()
20
{
21
if
(!playerTransform)
return
;
22
23
if
(playerTransform.transform.position.y > transform.position.y)
return
;
24
25
CheckPointManager
.
PlaceAtCheckPoint
(playerTransform);
26
}
27
28
#if UNITY_EDITOR
29
private
void
OnDrawGizmos()
30
{
31
Gizmos.color = Color.red;
32
Gizmos.DrawLine(
new
Vector2(-200, transform.position.y),
new
Vector3(200, transform.position.y));
33
}
34
#endif
35
36
37
}
CheckPointManager
Definition
CheckPointManager.cs:4
CheckPointManager.PlaceAtCheckPoint
static void PlaceAtCheckPoint(Transform playerTransform)
places playerTransform at the latest checkpoint stored
Definition
CheckPointManager.cs:13
FallDetectorScript
Controls what happens to a player if they fall below this object y position.
Definition
fallDetectorScript.cs:8
FallDetectorScript.Update
void Update()
Checks if the player transform falls below this objects y position and if so places the player at the...
Definition
fallDetectorScript.cs:19
Movement
Component that controls the movement of an object with a RigidBody2D.
Definition
Movement.cs:11
Assets
Scripts
fallDetectorScript.cs
Generated by
1.12.0