drag help please?

I have an example like the “Many Crates” example where objects fall constantly from the sky, and I make these draggable. But I have a few issues and wonder if anyone had any advice

* when i drag an item towards the ground, it starts moving wildly on the ground. I think this may be related to the circular collision issue, but in fact some of my items are boxes.

* objects are constantly added in front of the dragged object. should i re-insert it to the top constantly during dragging (or even in a “front drag” layer separate to the others)

* items hitting the dragged object are causing it to spin wildly. I’ve tried setting the angularDamping high but this made it turn in discrete angles eg an abrupt 15 degrees at a time rather than a smooth rotation (maybe i set it too high?)

* are there any other properties that would be a good idea to set on the object during dragging (i don’t really want fixed rotation though)

it’d be great if someone could adapt “many crates” with example drag behaviour, that doesnt give these issues. I’m not sure if it’s my code or a problem with the corona physics. note though my example is continuous (timer repeat = -1), removing crates that fall outside of the x bounds.

thanks
j
[import]uid: 6645 topic_id: 3540 reply_id: 303540[/import]

you can see this problem in action by including gameUI in the ManyCrates supplied example and adding

j:addEventListener("touch", gameUI.dragBody)  

at the end of the newCrate function, then draggring a crate down to the grass. is this expected behaviour that we need to add workarounds in for? I’m not really sure what

it also happens in the “DebugDraw” example without modification. drag the object down to the ground and it’ll start to oscillate wildy on its corners. in real world situations dragging a solid body on to the floor would still cause the object to stick to the ground. (let’s ignore the fact you can’t pull an elastic joint through solid ground in the real world!)

thanks
j

amend: seems the higher the maxForce on the drag joint, the worse the bounce oscillaiton will be when you hit the object against the ground, but we need maxForce high to keep the dragging near the center… not sure how to fix this.

as discussed here setting the body to “kinematic” as suggested in the docs causes Corona to crash with this error:

Exception Type: EXC\_CRASH (SIGABRT)  
Exception Codes: 0x0000000000000000, 0x0000000000000000  
Crashed Thread: 0 Dispatch queue: com.apple.main-thread  
  
Application Specific Information:  
Assertion failed: (d + step.dt \* k \> 1.19209290e-7F), function InitVelocityConstraints, file /Users/ansca/.hudson/jobs/Pong-DMG/workspace/platform/mac/../../external/Box2D\_v2.1.2/Box2D/Box2D/Dynamics/Joints/b2MouseJoint.cpp, line 114.  

http://developer.anscamobile.com/content/game-edition-physics-bodies#body.bodyType

kinematic objects are affected by forces but not by gravity, so you should generally set draggable objects to “kinematic”, at least for the duration of the drag event.
[import]uid: 6645 topic_id: 3540 reply_id: 10700[/import]