Skip to content

Commit

Permalink
Save
Browse files Browse the repository at this point in the history
  • Loading branch information
kmarkindev committed Apr 9, 2021
1 parent 7b024ed commit 9796b42
Show file tree
Hide file tree
Showing 9 changed files with 24,401 additions and 2 deletions.
10 changes: 9 additions & 1 deletion Assets/Prefabs/Car/Car.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ public class Car : MonoBehaviour, IResetable
private GameManager gameManager;
private Rigidbody rb;
public GameObject model;
public Transform initialTransfrom;
private Transform initialTransfrom;

public GameObject explosion;

private Animator animator;
private int turnLeftHash;
Expand Down Expand Up @@ -105,10 +107,16 @@ private void StopRotate()

private void OnCollisionEnter(Collision collision)
{
if (!hasControlls)
return;

string objTag = collision.gameObject.tag;
if (objTag == "Meteor" || objTag == "Rock")
{
rb.isKinematic = true;

Instantiate(explosion, transform.position, transform.rotation);

gameManager.GameOver();
}
}
Expand Down
2 changes: 2 additions & 0 deletions Assets/Prefabs/Car/Car.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
model: {fileID: 2971348555250844388}
explosion: {fileID: 8864119250051567657, guid: f30728ecec31ec244b08bf73d592b2c6,
type: 3}
speed: 15
rotationSpeed: 70
--- !u!65 &7438733422354135274
Expand Down
14 changes: 14 additions & 0 deletions Assets/Prefabs/Car/Explosion.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Explosion : MonoBehaviour
{
private void Start()
{
var ps = GetComponent<ParticleSystem>();
var main = ps.main;

Destroy(gameObject, main.duration);
}
}
11 changes: 11 additions & 0 deletions Assets/Prefabs/Car/Explosion.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 9796b42

Please sign in to comment.