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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by idlemurmurs · May 12, 2014 at 12:30 PM · collisiongameobjectplayerdetectioninteraction

Collision Detection When Picking Up GameObjects

Good Morning, Afternoon, Evening ... Night :)

I happened to stumbled across a rather head-scratching issue here at the moment. I scripted up a brand new script that allows the main player to pick up and interact with certain gameobjects. What this essentially translates to is that the specified gameobject is parented to the player at a specific local position, and will even follow all camera motions/movement.

One odd issue does arise from this however. In that though the specified gameobject remains a rigidbody throughout these interactions, still includes collisions, operates under a fixedUpdate function and the unity time has been set accordingly to increase collision detection. It doesn't collide with other gameobjects once parented to the player. The player movement essentially overrides all possibility of any legitimate collision.

So what occurs is that the specified gameobject just floats through all the environmental Gameobjects that are present. When in reality what I'd personallly wish to occur is that it collides with an object, remains steadfast and ceases the player the from moving any further (or rotating the camera) in particular direction.

And that's partially why I'm here tonight. So any thoughts, criticisms, light slander or useful tips would be much appreciated Thank you :)

Comment
Add comment · Show 5
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 snarf · May 12, 2014 at 01:02 PM 0
Share

some code would be nice :)

avatar image oliver-jones · May 12, 2014 at 01:33 PM 0
Share

show the code so we can help!

avatar image idlemurmurs · May 12, 2014 at 07:31 PM 0
Share

The code by nature is a relative mess,

hence why I didn't originally show it,

though the following should (hopefully) be those more relevant lines of code:

     var artifact    : GameObject;
     var character : GameObject;
     
     var artifactX   : float;
     var artifactY   : float; 
     var artifactY   : float;
     
      // Establishes The Set "GameObject" As Gravityless
      artifact.GetComponent(Rigidbody).useGravity =false;
     
     // Parents The Artifact To A Set Parent Location - "Character"
     // The Parent Being An Empty GameObject Parented To The $$anonymous$$ain Player With The $$anonymous$$ouselook   (Y) Script Attached
      artifact.transform.parent = character.transform;
     
      // Sets The "Vector3" Location Between The "GameObject" + Parent 
       var artifactLocation  = Vector3 (artifactX, artifactY, artifactZ); 
       artifact.transform.localPosition = artifactLocation;
avatar image snarf · May 13, 2014 at 07:16 AM 0
Share

I don't think that it's a good idea to have rigidbodies as children. The code that you've presented doesn't contain any errors/problematic solutions.

Have a look at this: http://answers.unity3d.com/questions/62497/-you-should-never-have-a-parent-and-child-rigidbod.html

If you're actually having children rigidbodies then to solve it you've got different options:

A. make a script that keeps the object in place, by applying force. There is an example of this in the standard assets provided by Unity.

B. attach a joint to the rigidbody

hope this helps :)

avatar image idlemurmurs · May 19, 2014 at 04:51 AM 0
Share

It wasn't quite the solution I was seeking,

Though you've most definitely been a fair help all the same, So I have reason to believe I owe you my thanks all the same. You've certainly introduced me to the knowledge surrounding rigidbodies. And the joint system has proven quite useful all the same.

So though you may well have sent me down the wrong internet rabbithole there, it proved to be relatively beneficial all the same. So thank you so much, as it sure helped! :)

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Pawscal · May 13, 2014 at 06:58 PM

Before parenting, i would try to change the Rigidbody's property "isKinematic" to true. The object should still interact with other physics enabled GameObjects, but you should be able to move it around as you want. Then, when you drop it dowm set back "isKinematic" to false.

Hope this helps!

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

23 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

Related Questions

How do I stop an immediate collision with all objects from ocuring at the entry of game mode? 0 Answers

Detecting Collision for Jumping 1 Answer

WALL collision detection problem... help!!!! 0 Answers

How to make a box (or any object) appear on collide? 1 Answer

collision wont work 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