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 KrazyKain · Sep 16, 2010 at 09:14 AM · collidercrashcharactercontroller

Unity crashes on certain collisions

So I'm working on an upwards scrolling space shoot em up.

The Player has a character controller and rigidbody and this code regarding the collisions (please ignore CamelCase errors and indenting)

function OnCollisionEnter(hit : Collision)

{ var targeto = hit.gameObject;

    if (targeto.tag == ("Enemy"))
    {
                    targeto.GetComponent(typeof (enemyBehaviour)).TakeDamage(100);
                    Boom();
    } 

}

Whenever the player collides with an enemy he damages the enemy ship and explodes. Now the strange thing is, sometimes the entire editor crashes when I do test this. The strange part is that it only happens sometimes, it seems to be only a second type of enemy, although they have all the exact same components and the same script, OR if I first shot an enemy before crashing into another.

if (Input.GetButtonDown("Fire1"))
    {
    var shotpos1= new Vector3(transform.position.x+0.5,transform.position.y,transform.position.z+2);
    var shotpos2= new Vector3(transform.position.x-0.5,transform.position.y,transform.position.z+2);
    var shot1 = Instantiate(shot, shotpos1, transform.rotation);
    var shot2 = Instantiate(shot, shotpos2, transform.rotation);
    }
}

(and in the bullets script)

function OnCollisionEnter(collision : Collision)
    {
        var targeto =   collision.gameObject;
        if (shotByPlayer == 1){
            if (targeto.tag == ("Enemy"))
            targeto.GetComponent(typeof (enemyBehaviour)).TakeDamage(shotPower);
            Destroy(gameObject);
        }
    {

Is the problem perhaps that OnCollisionEnter belongs to colliders and not character controllers?

or perhaps that Boom() involves deleting the the player gameobject, i.e. screwing with the very thing unity is acccessing?

edit: ok so apparently it only crashes if the player is moving manually. If the collision is due to the scrolling then its all fine, but if I ram the enemy everything crashes

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 KrazyKain · Sep 16, 2010 at 09:21 AM 0
Share

I've removed the destroy gameobject part of Boom() seemed fine for a while but after ram$$anonymous$$g a few enemys it crashed.. so "or perhaps that Boom() involves deleting the the player gameobject, i.e. screwing with the very thing unity is acccessing?" is unfortunately not it :(

avatar image CaffeinatedTech · Nov 01, 2012 at 12:10 AM 0
Share

I'm experiencing the same problem. I have a projectile that seems to cause Unity to freeze up sometimes when it hits a kinematic block. It also freezes on the android build.

Not sure exactly how to recreate it, seems very intermittent.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Ehren · Oct 01, 2010 at 09:23 PM

I'm having a similar issue. In my case it seems to only happens when I collide in an up-and-to-the-left direction with the object that gets de-activated.

I'd suggest trying to create a level where it happens every time. Then file a bug report and attach the project.

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

1 Person is following this question.

avatar image

Related Questions

Turn On - off character controller script, is there a way?? 3 Answers

how to make player collide for swimming 1 Answer

Character glitching on Ragdoll 0 Answers

How to stop CharacterController during Collider's moving? 0 Answers

Prevent player to walk over items, but without limiting their ability to place other items on it 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