Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by RobotReebot · Jun 19, 2015 at 08:01 AM · collisionprefabbug-perhaps

Problem with a prefab, need help

Hi.

I am making a videogame in 2D that is in the space. I wanted to give some cool effects to the spaceship, so i put under them an afterburner.

I want that when they hit a black hole their size will fall off, but iget the bug on video. How can i solve it?

The video click me

This is the script on hit with "Buco Nero" And it's attached to the player (Dark hole)

 using UnityEngine;
 using System.Collections;
 
 public class ContattoConBucoNero : MonoBehaviour {
     float perditamassa;
     int stack;
     float time;
     GameObject afterburner;
     // Use this for initialization
     void Start () {
         GetComponent<Transform> ().localScale = new Vector3 (2.631793f, 2.631793f, 0.3427396f);
     }
   
     // Update is called once per frame
     void Update () {
   
     }
     void OnCollisionEnter2D(Collision2D myCollider){
         if (myCollider.gameObject.tag == "Buconero") {
             afterburner=this.transform.GetChild(1).gameObject;
             perditamassa=FindClosestBucoNero().GetComponent<CreazioneBucoNero>().stack*0.15f;
             stack= FindClosestBucoNero().GetComponent<CreazioneBucoNero>().stack;
             if(perditamassa<(GetComponent<Transform>().localScale.x-2.631793f)){
                 GetComponent<Transform>().localScale= new Vector3(GetComponent<Transform>().localScale.x-perditamassa,GetComponent<Transform>().localScale.x-perditamassa);
                 GameObject.Find("Main Camera").GetComponent<Camera>().orthographicSize=GameObject.Find("Main Camera").GetComponent<Camera>().orthographicSize-(0.3f*stack);
                 while (time<=2f) {
                     time+=Time.deltaTime;
                     afterburner.GetComponent<ParticleSystem>().startSize= GetComponentInChildren<ParticleSystem>().startSize-(0.76f*(2/stack));
                 }      
             }
             else{
                 Debug.LogWarning("Game Over");
             }
             Destroy(FindClosestBucoNero());
         }
     }
     GameObject FindClosestBucoNero() {
         GameObject[] gos;
         gos = GameObject.FindGameObjectsWithTag("Buconero");
         GameObject closest = null;
         float distance = Mathf.Infinity;
         Vector3 position = transform.position;
         foreach (GameObject go in gos) {
             Vector3 diff = go.transform.position - position;
             float curDistance = diff.sqrMagnitude;
             if (curDistance < distance) {
                 closest = go;
                 distance = curDistance;
             }
         }
         return closest;
     }
 
 }
 

Thanks for all the help

Comment
Add comment
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

0 Replies

· Add your reply
  • Sort: 

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

2 People are following this question.

avatar image avatar image

Related Questions

Can prefabs interact with scroll rect? 0 Answers

Destroy a specific prefab (GameObject) Unity2D 1 Answer

Tagged collision problem 1 Answer

Ignoring collisions without using physics layers 1 Answer

Odd behaviour when instatiated 1 Answer


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