Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by Wrockies · Aug 31, 2015 at 02:39 AM · c#triggercubekinematicimpact

How can I change an objects Kinematic state on impact with player?

So here's the deal, I created an object (a sheep) made out of cubes, that move in a circle (while kinematic). I want it to have an effect where when the player runs into the object, it will no longer be kinematic, essentially causing to fall into a little pile of cubes, and stop moving in a circle. Thanks for 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

1 Reply

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

Answer by GAMZER0 · Aug 31, 2015 at 04:20 AM

What you want to do is make an OnCollisionEnter function in the sheep class, and when the player collides with it, set the sheep kinematic to false: isKinematic = false; An example is this: (Note this code hasn't been tested.

 public Rigidbody SheepRB; //The sheep rigidbody
     
     void Start() 
     {
            SheepRB = GetComponent<Rigidbody>();
      }
     
     void OnCollisionEnter (Collision Col) 
         {
             if(Col.gameObject.tag == "Player")
             {
             SheepRB.isKinematic = false; //Turns off the Kinematic 
             }
             
         }
         
 
Comment
Add comment · Show 11 · 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 Wrockies · Aug 31, 2015 at 12:31 PM 0
Share

This is perfect thanks! $$anonymous$$y problem was I was using an OnTriggerEnter in the player class, and trying to transfer data to the sheep class somehow. I didn't think to just detect the collision from the sheep class. Good work :)

avatar image Wrockies · Aug 31, 2015 at 02:48 PM 0
Share

So I attempted this just now, and for some reason it is not working, and I cant seem to figure it out. Here is what I have: using UnityEngine; using System.Collections; public class Crumble : $$anonymous$$onoBehaviour { %|-609983407_1|% %|221694547_2|% %|373702738_3|% %|-448543543_4|% %|-1327985746_6|% %|-1110813548_7|% %|1691315859_8|% %|1471336863_9|% %|-747104344_10|% %|1802515232_11|% %|1888266136_13|% %|-1619529957_14|% }

I have this script applied to each cube, as well as the parent, and even the prefab that I used. Yet, when the ball passes through the sheep, nothing happens. Is there something I'm missing? Thanks.

avatar image GAMZER0 · Aug 31, 2015 at 03:38 PM 1
Share

What exactly does those codes do that's inside your crumble class? Also make sure player isn't kinematic, and all the objects rigidbodies "Collision detections" is set to continuous

avatar image Wrockies · Aug 31, 2015 at 03:48 PM 0
Share

Ah I didnt have my objects set to continuous collision. Thanks again!

avatar image GAMZER0 · Aug 31, 2015 at 03:57 PM 1
Share

No problem, if it still doesn't work just let me know, and I'll try to come up with different solutions to what could be the problem.

Show more comments

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

28 People are following this question.

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

Related Questions

Help with a door slam trap 0 Answers

Any ideas in relate to a cube rolling? thank you! 0 Answers

Any way to fix an tag change problem? 1 Answer

How to change isKinematic only in one scene C# 1 Answer

Unity3D: Objects destroy automatically 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