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 Timmyglen2 · Jan 06, 2011 at 09:59 PM · javascriptphysicsmoving-platform

Be able to grab something and hold on to it.

I am making a game where an integral part of it is that I would be able to pick up cubes and move them to different places, as well as grab ahold of a moving platform from the bottom so that I move with it. One of my ideas (actually the idea that I want), is to be able to make the cube sticky (by adding a joint when it collides), and then stcking it to the underside of the moving platform. However, I don't know how to hold an object in that way. I can't make it a child of the camera, because then when it moves the character and camera won't, but if I make my character be a child of the cube, then I can't move the cube. A javascript would be nice. Thanks in advance.

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 Peter G · Jan 07, 2011 at 02:25 AM

Parenting is the easiest way, but you said you cannot use that. Next would probably be simply setting the cubes position to be right in front of your character.

//PlayerController.js private var pickedUpObj : Transform;

function Update () {

  //Add code for selecting an object.  The easiest way is probably Physics.OverlapSphere()

 pickedUpObj.position = transform.position + transform.forward;
 //Places the cube 1 unit in front of the player.

}


If your player is controlled by a Rigidbody, then you could add a FixedJoint to your cube and it will stick.

Comment
Add comment · Show 2 · 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 Timmyglen2 · Jan 07, 2011 at 10:38 PM 0
Share

and if I use this, when the cube is forcefully moved, I will be too?

avatar image Peter G · Jan 08, 2011 at 12:38 PM 0
Share

No, sorry, in that case you should probably opt for a Physics controlled character and then use a Fixed or hinge joint. Even still, I don't know if forces on the child rigidbody move the parent. I would guess yes, but you need to test that.

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

How do I switch from Character player to Airship Vehicle using triggers? 0 Answers

Best way to go about having many fast objects with physics 0 Answers

How to 'flick' objects in a 2d game 1 Answer

CharacterController falls through or slips off moving platforms 9 Answers

Raycast to Terrain (Conditional Statements) 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