Draggable and collision


#21

Ok, I’ve finally tried it (sorry about the delay =p) !
Thing is, I have many blocs to move and not only one bloc and obstacle (like it seems to be in your game).
So moving bloc1 to bloc2, which is also an object with physics, just push it away ! Because its dynamic type. But if turn it static, I wont be able to move it anymore.

EDIT :
OK I’ve add in the press and realse event, something that change the type. It working !
Now, I would like to get rid of all the other physics movement. I am good with the boucing by setting resistution to 0, but how do I make the bloc instantely stopping when the drag stops ?
Its actually keeping to move in the direction I was dragging.


#22

My game a has about a half dozen objects that can be dragged. I just showed you one so you get the idea of how to do it:


Do you set the object to static when the mouse is released?


#23

Ok thanks MrMen, its working with your last advice :

Still, I must be too requiring, but the kind of movement the bloc has, when being dragged, doesnt fit with my game. Is there a way I can make this different ?

Can the bloc be directly following the cursor, from very close, even if I drag it quickly and from long distance ?

Or even more cool, can the bloc still get the kind of movement I had at the very begining ? Which is moving on a grid, from spot to spot.


#24

You can make it different, but it would require different code. You could have a play round with different type of joints, as the mouse one has an elastic feel to it. Otherwise you’ll have to devise a different way of dragging.


This is definitely an option. It’s be best to look into the “Snap objects to virtual grid” extension for this (open Project Manager, expand Functions/Behaviours and click on “Search for new extensions”)


#25

Changing the force of the mouse joint to 500n makes it move si quickly to the target position, that there is no longer any elastic feeling, perfect for me !

I’ll now check if I can make this works with the snap to grid extension. Thanks a lot again !


#26

Hey there !

Got another trouble. One of my shape, is not a square/rectangle, but lie the Z shape in tetris.
How do I deal with this one and physics engine for collision ?

I’ve tried to add a custom mask, but I didnt work …

Right now, its still acting as if it where a rectangle…

Thanks a lot !


#27

Unfortunately, physics collision doesn’t use the sprite hitbox. The physics collision area and sprite hitbox are 2 different, separate entities. And to top it off, I don’t think you can define multiple areas for physics collision.

Is there something that physics engine provides that you need? Or can you program it all with the standard collision and deal with dragging via events?


#28

You can make two sprites instead of one, then update its position to the point of the other
One sprite for 101 and other sprite for 110 so set a point in between then position the 101 to the point you set in 110 so their hitboxes will be separated as per sprite.


#29

I would like to try this, but can’t figure out were to type in the 500n. Could you please let me know?

Thanks!


#30

Hi ! What do you mean by 500n ?


#31

What do you mean? You’re the one who wrote it earlier:


#32

Woops, sorry =p

Its in there :slight_smile:


#33

Hey there.

I am back to focus this part of my game and the troubles are back too =p

I’ve tried to have 2 different parts of the “S” shape block. To keep them linked, I’ve used those events :

But since both y blocks became dynamic one I drag on off them, the 2 differents events trigger.
How can I make part1 following part2 and part2 following part1 without using X and Y positions.