Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 Artium · Apr 26, 2011 at 05:37 PM · collisionrigidbodycolliders

Colliding fast moving object with a slow moving object

I read few tutorials and examined several examples of collision detection, but was not able to understand how to do it properly. Each tutorial/example seems to use different technique.

I did some small demo with fast rockets and slow enemies, but it does not work as expected. The rockets sometimes "explode" in thin air, and when colliding with an enemy, only the rocket explodes (the enemy should explode as well).

I hope someone could sort it out and point me to the right technique to use.


I use the following method to detect a collision for an enemy:

var speed; var explosion : GameObject;

function FixedUpdate () { transform.Translate(Vector3.forward speed Time.deltaTime); }

function OnCollisionEnter(collision : Collision) { if (collision.gameObject.tag != "Plane") { var contact : ContactPoint = collision.contacts[0]; if(explosion) Instantiate(explosion, contact.point, Quaternion.LookRotation(contact.normal) ); Destroy(gameObject);
} }

Enemy is a Box collider and rigid body with "continuous collision detection"

In rocket, I use the following collision script:

function Update ()
{
    transform.Translate(Vector3.forward * speed * Time.deltaTime);
    var hit : RaycastHit;
    if(Physics.Raycast(transform.position, transform.forward, hit, speed * Time.deltaTime))
    {
        if(explosion) Instantiate(explosion, hit.point, Quaternion.LookRotation(hit.normal) ); 
        Destroy(gameObject);    
    }
}

The rocket is not rigidbody.

Comment
Add comment · Show 3
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 Muzz 1 · Apr 26, 2011 at 06:40 PM 0
Share

Does the rocket have a box collider?

avatar image Artium · Apr 26, 2011 at 07:50 PM 0
Share

Yes, the body of the rocket has a box collider.

avatar image cregox · Sep 27, 2011 at 06:40 PM 0
Share

related: http://answers.unity3d.com/questions/124344/player-falling-too-fast-for-a-collider-to-stop-it.html

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Clunk · Sep 28, 2011 at 12:28 AM

All scripting aside for now, try this. Make the rocket a rigidbody. Set collision Detection on the rigidbody settings of the rocket to Continuous Dynamic. Give the enemy a rigidbody collider as well. If necessary, set the enemy's rigidbody to isKinematic, and disable isKinematic upon collision. Make sure the enemy's rigidbody setting for Collision detection is set to "Continuous". If this is not set correctly, for example, it is set to Discrete, the fast moving object will go through other objects. So just keep in mind, "Continuous Dynamic" for fast moving object, "Continuous" for objects the fast mover will collide with.

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

2 People are following this question.

avatar image avatar image

Related Questions

Ragdoll with multiple colliders 0 Answers

stop objects moving through each other 5 Answers

Adding components to 3d models 1 Answer

Connect a collider with a rigidbody ?? 1 Answer

How to make two colliders or rigidbodies stick together upon collision, as if there was a glue on their surfaces? 3 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