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 Kaasha · Mar 18, 2013 at 08:13 PM · dragkeyboard

Drag object using only keyboard in 2d sidescroller

Hey guys (sorry if repeating - having troubles forums...) im making 2d sidescroller puzzle game (using only keyboard) with push-pull/drag objects (drag/pull box to some place to be able to jump on some higher surface).. i set up push object script using AddForce, but i cant find any tutorial or script itself for dragging object on collision (character standing near box to drag/pull it holding down button i.e. "E").. maybe something similar like now so popular LIMBO game.. can anyone help me with this?

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 robertbu · Mar 18, 2013 at 11:54 PM 0
Share

There are multiple ways of pulling. You can create a joint between two object (can work well with Rigidbodies), you can "magnetize" one object so that either based on a state or distance it will use force to drive itself towards an other object, you can write a script that pulls an object towards another using Transform.Translate(), and you can make an object a child of another object. If you decide on an approach given your game mechanics, I can probably point you to more information or a sample script.

avatar image Kaasha · Mar 19, 2013 at 06:26 PM 0
Share

can that magnetism be made with "hit" or "on key" mode? as i'm desperate trying out things with this option.. and just to make sure.. those child of object's u mean like "Stick" under player object and if that stick is colliding with "box" then its starts pulling? if so i would be very happy if u could provide some sample script for that :3

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by dorpeleg · Mar 18, 2013 at 08:46 PM

Just out of my head, did you try negative AddForce? (never worked with AddForce so not sure if this works)

If that doesn't work, You can try setting some bool if the object is being dragged and if so, make it's position close to your character position.

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 Kaasha · Mar 19, 2013 at 06:22 PM 0
Share

yes i tried negative force and i couldn't make it work :C tho idea about position near char seems possible tho don't really know how to do that :3

avatar image dorpeleg · Mar 19, 2013 at 07:20 PM 0
Share

Here is my thought about this:

Add a trigger area to your dragable object (add a collider and check the trigger box).

Then, have a check for when entering the trigger area, follow the player (direction doesn't matter).

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

11 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

Related Questions

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Moving a rigidbody onto exact mouse position using rigidbody.MovePosition? 1 Answer

Another camera drag script, can anyone figure out these errors? 1 Answer

Passing stuff from script to script (setting change-able waypoints) .... 1 Answer

OnDrag Draw Line For Pathfinding... 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