FCV Engine 0.1
A tool and framework for tutorials in game development
Loading...
Searching...
No Matches
fallDetectorScript.cs
1using System;
2using UnityEngine;
3using UnityEngine.SceneManagement;
7public 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}
static void PlaceAtCheckPoint(Transform playerTransform)
places playerTransform at the latest checkpoint stored
Controls what happens to a player if they fall below this object y position.
void Update()
Checks if the player transform falls below this objects y position and if so places the player at the...
Component that controls the movement of an object with a RigidBody2D.
Definition Movement.cs:11