playMaker

Author Topic: Touch drag object without passing through other objects  (Read 2020 times)

Redhawk

  • Junior Playmaker
  • **
  • Posts: 57
    • View Profile
Touch drag object without passing through other objects
« on: June 04, 2014, 03:28:17 AM »
I'm having a really hard time figuring out how to get my object(s) to move via touch drag or swipe without moving through other objects.  I want to drag an object towards a wall, but even if I hit the wall and drag further, the object stops at the wall (and doesn't bounce back).  Also, if I hit other objects or other moveable objects, the dragged object stops.  I've tried adding force and collisions, but the object hits the opposing obstacle and either bounces back or skirts up/down/alongside the object.  Also if it hits a moveable object, either both objects move or it bounces back. 

This is the key mechanic of the game I'm trying to help my 10 year old make, but I can't get it working.

Flying Robot

  • Sr. Member
  • ****
  • Posts: 293
  • Od ton yebo redro
    • View Profile
    • Flying Robot Studios
Re: Touch drag object without passing through other objects
« Reply #1 on: June 06, 2014, 05:57:24 AM »
You need to set up a hinge joint to get the collisions working. Check the attached scene.


Redhawk

  • Junior Playmaker
  • **
  • Posts: 57
    • View Profile
Re: Touch drag object without passing through other objects
« Reply #2 on: June 06, 2014, 10:52:37 AM »
The object (cube) bounces all around when it hits the wall.

Flying Robot

  • Sr. Member
  • ****
  • Posts: 293
  • Od ton yebo redro
    • View Profile
    • Flying Robot Studios
Re: Touch drag object without passing through other objects
« Reply #3 on: June 06, 2014, 11:05:25 AM »
Yes, that's the way it should be. You can play with the mass, drag and other parameters, including tweaking the physics manager of the scene. But, when you push two rigid bodies continuously, the behavior can be unexpected and jittery.

I don't know why you need RB collisions to move things around. Objects can interact more predictably by using triggers and collision detection.

Redhawk

  • Junior Playmaker
  • **
  • Posts: 57
    • View Profile
Re: Touch drag object without passing through other objects
« Reply #4 on: June 06, 2014, 07:14:44 PM »
I have no preference actually.  I just want to get the movement to work.  I don't care what method.  I actually have no clue what method is best.  End result is that I want to move a block (each block can go either horizontal OR vertical, but not both) which does not go through walls or other blocks.  Then move a block to the goal.

The image is what I'm trying to do, but I can't figure out the best way to do it.
« Last Edit: June 06, 2014, 07:25:07 PM by Redhawk »

Flying Robot

  • Sr. Member
  • ****
  • Posts: 293
  • Od ton yebo redro
    • View Profile
    • Flying Robot Studios
Re: Touch drag object without passing through other objects
« Reply #5 on: June 06, 2014, 07:28:06 PM »
Then you are better off with using a character controller. It's more stable and I think the attached scene is what you are looking for.


Flying Robot

  • Sr. Member
  • ****
  • Posts: 293
  • Od ton yebo redro
    • View Profile
    • Flying Robot Studios
Re: Touch drag object without passing through other objects
« Reply #6 on: June 06, 2014, 08:02:34 PM »
I hope you will get the hint from the previous package, if not, here's a more complete system.