Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
2 captures
12 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 em2 · Aug 17, 2011 at 04:10 AM · collisioncollidergravityfreezefreezeposition

How do I “freeze” an object after a collision?

How do I “freeze” an object after a collision? I have a spear that is being instantiated and has velocity toward a target. When it hits the target I want it to stay stuck into the target and stay there without being dislodged by other spears. (I guess I want to deactivate / hide / remove the spears collider after it hits??). The reason I want to hide the spears collider is that if the next spear hits the same spot it’s going to knock the first one over.

Also the spear is a rigidbody, so when I’m setting transform vector 3 to 0,0,0 the object isn’t sticking in to the target, it stops moving forward but it is still slowly falling to the ground. I’ve used this code and put this on the original spear object:

 function OnCollisionEnter(hit : Collision){
    if(hit.gameObject.tag=="myTarget"){
      transform.Translate(Vector3(0,0,0));//stop cloned spear moving
      transform.Rotate(Vector3(0,0,0));//stop cloned spear rotating
      rigidbody.useGravity = false; //stop it falling to ground
      print("You hit the target");
     }
 }

Any help to "freeze" and then isolate an object after a collision with a target would be greatly appreciated.

Cheers Chris

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 meat5000 ♦ · Feb 15, 2016 at 08:56 PM 0
Share

Ok this is old but it resurfaced to page 1 so Im adding my 2p.

To freeze an object (rigidbody) I would make it $$anonymous$$inematic on impact. To stop something colliding remove its collider (assu$$anonymous$$g $$anonymous$$inematic).

avatar image kfidanci · Jul 25, 2021 at 06:15 PM 0
Share

I just want to use above code for my specific project. How can I make it work? I got a error doing it.

3 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by henry96 · Aug 17, 2011 at 04:49 AM

I think u should make an empty object which has box collider and set it to trigger. Then, parent ur spear to that empty object. After that, u write some codes that if the new spear trigger the empty gameobject. Then remove the old spear. Hope this help!

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 em2 · Aug 17, 2011 at 05:41 AM 0
Share

Hi Henry96, thanks for the response. What I have has worked once I clicked on the trigger check box. I needed to do that so it stopped the other physics collisions on the spears. It has developed a lag in the collisions on the target now though, but I think that's going to be a different issue. Thanks again. Cheers Chris

avatar image
0

Answer by em2 · Aug 17, 2011 at 04:23 AM

I found part of the answer here: http://answers.unity3d.com/questions/150203/pause-gameobject-motion.html

The second part was, how to handle collisions with other spears hitting the one already stuck in the target??

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 alla_it93 · Feb 16, 2016 at 12:59 PM

use Is kinmatic property -> rigid body to freeze the spear once hit the target

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

6 People are following this question.

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

Related Questions

Collision in between 2 objects moving away from each other? 1 Answer

Allow picked up object to collide with game level GameObjects 1 Answer

How to make player collide with ground? 1 Answer

Objects rotating after falling on another object with Physics & Gravity? 1 Answer

Falling object on collision 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