Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Collider Help
Having trouble with the boundary and destroy by boundary script. It is not deleting when bullets come in contact.
  • Loading branch information
aps16104 committed Feb 18, 2020
1 parent 9bcea67 commit 2f63e73
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
8 changes: 4 additions & 4 deletions SpaceShooter/Assets/Prefabs/Bolt.prefab
Expand Up @@ -27,8 +27,8 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2786470009650213004}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalPosition: {x: 0, y: 0, z: 1}
m_LocalScale: {x: 0.25, y: 0.75, z: 1}
m_Children:
- {fileID: 5826147667051634208}
m_Father: {fileID: 0}
Expand Down Expand Up @@ -68,8 +68,8 @@ CapsuleCollider2D:
m_IsTrigger: 1
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_Size: {x: 0.17020008, y: 0.35282898}
m_Offset: {x: -0.005437523, y: -0.0036384861}
m_Size: {x: 0.24275368, y: 0.37455338}
m_Direction: 0
--- !u!114 &1073888857780383466
MonoBehaviour:
Expand Down
16 changes: 16 additions & 0 deletions SpaceShooter/Assets/Scripts/DestroyByBoundary.cs
@@ -0,0 +1,16 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class DestroyByBoundary : MonoBehaviour
{
//void OnTriggerExit2D(Collider2D other)
// {
// Destroy(other.gameObject);
//}

void OnTriggerExit(Collider other)
{
Destroy(other.gameObject);
}
}
11 changes: 11 additions & 0 deletions SpaceShooter/Assets/Scripts/DestroyByBoundary.cs.meta

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

15 changes: 15 additions & 0 deletions SpaceShooter/Assets/Scripts/PlayerController.cs
Expand Up @@ -12,6 +12,21 @@ public class PlayerController : MonoBehaviour
public float speed;
public Boundary boundary;

public GameObject shot;
public Transform shotSpawn;
public float fireRate;

private float nextFire;

void Update()
{
if (Input.GetKeyDown("space") && Time.time > nextFire)
{
nextFire = Time.time + fireRate;
Instantiate(shot, shotSpawn.position, shotSpawn.rotation);
}
}

void FixedUpdate()
{
float moveHorizontal = Input.GetAxis("Horizontal");
Expand Down

0 comments on commit 2f63e73

Please sign in to comment.