Drag and Drop and Swap Location
Nabbo (ReflectiveByte)
Member Posts: 278
Hello All, I am working on an RPG and I am stuck at one thing... hope someone can help..
I am making an inventory like scene in RPG.. Here are the steps that I follow where I am stuck:
1. Touch to start dragging an item (Done I know this step)
2. When item is overlapping another item and is released I want both Items to swap places (Oh this is making me crazy I tried so many options but it goes bad)
3. When item does not overlap anything and touch is released it goes back to its location (Done I know this step)
Hope you got the idea..
Current Projects I am working on: Stupid Duck, Zango's Shark Adventure, AoD: Age of Dragons, Rocket Jump: The Pixel Invaders
Facebook: https://facebook.com/reflectivebytegamestudios
Web: reflectivebyte.com
Comments
One challenge to think about (it might push you in the right direction):
If you have an inventory with slots close to each other, it might be touching more than one other item. How do you resolve such a situation?
You'll need more than just an overlap rule.
Not necessarily. You could make a custom collision shape for the actors that´s small enough so that it won´t collide with more than one actor at a time.
Mental Donkey Games
Website - Facebook - Twitter
True, but it depends on needs and circumstances. The biggest issue with that is that if the CC shape is too small, then you will end up with the opposite problem, where it doesn't swap in situations where visually it should be (the images overlap, but the CC, which you don't see, don't). Especially if swapping the items is not the only thing you do with them, you might need them to effectively collide and interact with other items in the game. I'm sure there might be a sweet spot.
And there will be many different ways how to tackle this specific problem, depending on your other gameplay needs.
@pHghost That is definitely true. Can be done in many different ways, and what´s the best method depends on lots of things.
Mental Donkey Games
Website - Facebook - Twitter
thx @uptimistik @pHghost @MentalDonkeyGames .. I will try drag and drop if it goes kool without any issues or else I will change it to click and replace.. I will update the results
Current Projects I am working on: Stupid Duck, Zango's Shark Adventure, AoD: Age of Dragons, Rocket Jump: The Pixel Invaders
Facebook: https://facebook.com/reflectivebytegamestudios
Web: reflectivebyte.com
@uptimistik thx this one worked great!! Now I made great Progress.. However I also used the following tutorial. Well I didnt use drag function it made it so buggy.
Current Projects I am working on: Stupid Duck, Zango's Shark Adventure, AoD: Age of Dragons, Rocket Jump: The Pixel Invaders
Facebook: https://facebook.com/reflectivebytegamestudios
Web: reflectivebyte.com