Skip to content

Commit 606b078

Browse files
committed
Added some more thigns
Added breakable floors, moving script, and option to not kill the player on hazards
1 parent f223e6b commit 606b078

File tree

9 files changed

+71
-2
lines changed

9 files changed

+71
-2
lines changed
7.58 KB
Binary file not shown.

Example-UnityScript/Assets/Prefabs/BreakawayFloor.prefab.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
1.97 KB
Binary file not shown.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
public class Breakway : MonoBehaviour {
6+
void OnTriggerEnter(Collider other) {
7+
StartCoroutine (BreakFloor ());
8+
}
9+
10+
IEnumerator BreakFloor() {
11+
yield return new WaitForSeconds (3);
12+
Destroy (this.gameObject);
13+
}
14+
}

Example-UnityScript/Assets/Scripts/Breakway.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Example-UnityScript/Assets/Scripts/Hazard.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
using UnityEngine;
22

33
public class Hazard : MonoBehaviour {
4+
public bool killPlayer = true;
5+
46
// Option if this should be destroyed if touched
57
public bool removeOnHit = true;
68

79
void OnTriggerEnter(Collider other) {
810
// Find the game controller
911
GameController gc = GameObject.FindGameObjectWithTag ("GameController").GetComponent<GameController> ();
1012

11-
// Call the RespawnPlayer() method from the game controller
12-
gc.RespawnPlayer();
13+
if (killPlayer) {
14+
// Call the RespawnPlayer() method from the game controller
15+
gc.RespawnPlayer ();
16+
}
1317

1418
// If the "removeOnHit" is true, then we destroy this game object to remove it from the world
1519
if (removeOnHit) {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
public class MoveIt : MonoBehaviour {
6+
Vector3 initialPosition;
7+
8+
public float amplitude = 4.5f;
9+
10+
// Use this for initialization
11+
void Start () {
12+
initialPosition = this.gameObject.transform.position;
13+
}
14+
15+
// Update is called once per frame
16+
void Update () {
17+
this.transform.position = initialPosition + new Vector3 (0.0f, Mathf.Sin (Time.time) * amplitude, 0.0f);
18+
}
19+
}

Example-UnityScript/Assets/Scripts/MoveIt.cs.meta

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
36 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)