Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by Creative Inventory · Oct 24, 2015 at 08:37 AM · objectdestroyboundary

Boundry destroy problem

I have a 2D asteroid game which spawn moving asteroids (spawn box) from left , right, above and below my main camera view. My original asteroids (objects) where place far away from my main camera and my spawn boxes so it wouldn't come in at i time i didn't give it. I made a boundary box around my main camera and my spawn box so it can destroy any asteroids (objects) that goes beyond that point. but it didn't work. My problem is how can i make a boundary box using a box collider that destroy any objects that goes beyond it. WITHOUT destroying my original asteroids (objects). Here's my boundary script :

using UnityEngine; using System.Collections; public class DestroyByBoundary : MonoBehaviour { void OnTriggerExit(Collider other) { Destroy(other.gameObject); } }

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Statement · Oct 24, 2015 at 01:44 PM 0
Share

"but it didn't work"

They don't get destroyed, or how does it fail? Or does it destroy them prematurely?

avatar image Creative Inventory · Oct 25, 2015 at 09:27 AM 0
Share

What I mean is: 1) I have original asteroids out side my main camera view 2) I need the original asteroids so that it can spawn clones within my main camera view 3) $$anonymous$$y clone asteroids have a movement script attach to it so it can move in and out of my camera view 4) I want to destroy the clone asteroids once it exits the main camera view, without destroying the original asteroids 5) I've tried doing with a collision box out sides main cameras view, but it didn't work 6) How can I destroy my clone asteroids without destroying the original asteroids

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Statement · Oct 25, 2015 at 10:22 AM

I will assume your "original asteroids" (hereafter called prefabs) are not moving around in your scene. If they are, stop moving your prefabs around at runtime because it doesn't make sense. With the information given, the only way the prefabs would get destroyed would be if they enter and then exit the Boundry.

Consider disabling the prefab gameobject so it is inactive at runtime (no longer moving around, rendering, triggering stuff etc). When you instantiate a asteroid clone from an inactive prefab, active the clone with clone.gameObject.SetActive(true).

The most common way to work with prefabs is to make them assets and not have them hanging around in your scene. With that approach you won't have to worry about the prefabs interacting with your game.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

33 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

I need help deleting cloned objects at a axis point 0 Answers

Some coding help needed 1 Answer

Destroying a spawn object when it exit the main camera view not working 0 Answers

Can you get a value from a object when destroyed? 2 Answers

Destroy moving objcts through touch on screen 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges