Skip to content

Commit 9796b42

Browse files
committed
Save
1 parent 7b024ed commit 9796b42

File tree

9 files changed

+24401
-2
lines changed

9 files changed

+24401
-2
lines changed

Assets/Prefabs/Car/Car.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ public class Car : MonoBehaviour, IResetable
66
private GameManager gameManager;
77
private Rigidbody rb;
88
public GameObject model;
9-
public Transform initialTransfrom;
9+
private Transform initialTransfrom;
10+
11+
public GameObject explosion;
1012

1113
private Animator animator;
1214
private int turnLeftHash;
@@ -105,10 +107,16 @@ private void StopRotate()
105107

106108
private void OnCollisionEnter(Collision collision)
107109
{
110+
if (!hasControlls)
111+
return;
112+
108113
string objTag = collision.gameObject.tag;
109114
if (objTag == "Meteor" || objTag == "Rock")
110115
{
111116
rb.isKinematic = true;
117+
118+
Instantiate(explosion, transform.position, transform.rotation);
119+
112120
gameManager.GameOver();
113121
}
114122
}

Assets/Prefabs/Car/Car.prefab

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ MonoBehaviour:
6767
m_Name:
6868
m_EditorClassIdentifier:
6969
model: {fileID: 2971348555250844388}
70+
explosion: {fileID: 8864119250051567657, guid: f30728ecec31ec244b08bf73d592b2c6,
71+
type: 3}
7072
speed: 15
7173
rotationSpeed: 70
7274
--- !u!65 &7438733422354135274

Assets/Prefabs/Car/Explosion.cs

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 Explosion : MonoBehaviour
6+
{
7+
private void Start()
8+
{
9+
var ps = GetComponent<ParticleSystem>();
10+
var main = ps.main;
11+
12+
Destroy(gameObject, main.duration);
13+
}
14+
}

Assets/Prefabs/Car/Explosion.cs.meta

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

0 commit comments

Comments
 (0)