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 MechWarrior117 · Apr 21, 2011 at 06:55 PM · collisionterrain

Can't crash airplane into ground

I'm having a problem crashing my jet into the ground for the flying game. It keeps just passing though, and I want it to vanish. Can anyone help? thanks.

here is some code:

function OnControllerColliderHit(theCollision : Collision){
    if (theCollision.gameObject.name == "Ground"){
        Destroy(gameObject);
    }
}

EDIT: I have colliders on both my jet and the terrain.

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 AngryOldMan · Apr 21, 2011 at 07:19 PM 0
Share

if your terrain and jet are too big the collision detection will be too much for unity to handle. What kind of collision are you using for the jet? $$anonymous$$esh, box, sphere, etc

avatar image MechWarrior117 · Apr 21, 2011 at 08:05 PM 0
Share

Im using a mesh collider

4 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Peter G · Apr 21, 2011 at 07:20 PM

For starters, you have to be moving your object with Controller.Move() to have the collisions calculated for the CharacterController and to have the OnControllerColliderHit() to be called. If you are not doing that, then you won't get collisions/messages.

Another note, you probably don't want to have a character controller on a jet. CharacterControllers are designed for characters. They don't work well for other things. The shape hints at a bipod, and you have to add your own physics.

I would suggest that you use Rigidbodies and a combination of colliders (or a mesh collider) to control your jet.

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
avatar image
1

Answer by AngryOldMan · Apr 21, 2011 at 10:51 PM

If you are using a rigidbody for your player then it needs colliders (try using primitives instead of a mesh collider) to detect collisions and like Peter G says it needs to use rigidbody.AddForce (or .velocity) If you are using a character controller make sure you are using transform.translate to move the CHARACTER CONTROLLER and not transform.position to move the OBJECT (which is where I made my 1st ever unity mistake the moment i tried scripting)

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
avatar image
0

Answer by MechWarrior117 · Apr 21, 2011 at 08:03 PM

k, I made it into a rigid body and revised the code to this:

function OnCollisionEnter(theCollision : Collision){
    if (theCollision.gameObject.name == "Ground"){
        Destroy(gameObject);
    }
}

however, it still doesn't seem to work as the jet just phases though the ground still. Am I doing this right? thanks for the replies.

Comment
Add comment · Show 1 · 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
avatar image Peter G · Apr 21, 2011 at 08:30 PM 0
Share

Are you moving your object with the movement classes in Rigidbody, such as Rigidbody.AddForce()?

avatar image
0

Answer by MechWarrior117 · Apr 22, 2011 at 09:35 PM

K, im not sure if I worded it right. What I want is for the plane to just dissapear (or stop dead) when it hits the terrain. I don't want it to bounce or anything like that. Its a case where I want the plane to perform a function when a collision is triggered. I tried some of the above ideas, but I still haven't been able to get the plane to do this.

Sorry.

But, yeah, while these ideas are great, the problem is still unsolved for me. Any more help is much appreciated, and thankyou to those who took time out their day to help me :)

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

No one has followed this question yet.

Related Questions

Terrain collision problem 1 Answer

Make a simple tree 1 Answer

Terrain Detail Mesh Collisions 1 Answer

Collision Problem - Terrain collider remains flat after raising or lowering it 0 Answers

A.I. units partially sinking in to the terrain, on just one location 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