Skip to content
Permalink
Browse files

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 2f63e73366f8e09b194ff65276cc0a7fed31b493
@@ -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}
@@ -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:
@@ -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);
}
}

Some generated files are not rendered by default. Learn more.

@@ -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");

0 comments on commit 2f63e73

Please sign in to comment.
You can’t perform that action at this time.