• 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 ExpiredIndexCard · Apr 30, 2013 at 04:59 AM · rigidbodyattachpushpull

How can I make my player push objects?

I'm making a 2.5 D action game and i want my player to be able to push desks to use as barricades. My desks have joints so that I can fake destructible objects. I want my player to be able to attach to the desk from one side and be able to push or pull. How can i accomplish this? No scripts needed just show me links or tell me what to do thanks!!

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 tyjkenn · Apr 30, 2013 at 05:14 AM

Use OnCollisionStay. Check if the contact point is left or right of the player. If contact.x-position.x > 0 it is to the right. If it is <0, it is to the left. Also add some conditions on y to make sure it is at pushing height. If the player is moving in the same direction, add a force to assist with the push. If a button is also being pressed (for holding) and the player is moving away, translate the object with the player.

During the pushing, you could temporarily change the joint variables. Disable it, or set the break force and torque to infinity. Then change it back when you lose contact.

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 ExpiredIndexCard · Apr 30, 2013 at 05:21 AM 0
Share

Yes but i have joints on the object. It will break the joint or move it out of proportion. How do i do this without disturbing the joints

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

13 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

Related Questions

Amnesia like objects, in unity. 2 Answers

Cube collision problems when held 0 Answers

What is the best way to Push or Pull an Object? 2 Answers

Rigidbodies push other rigdidbodies 1 Answer

Method for grabbing rigidbody 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges