Trade positions of 3 objects/cards

hmm sorry for the unclear question. the one im trying to do here is that i have 3 cards which is horizontally arrange

so my 1st card is in 1st spot, 2nd card in 2nd spot, 3rd card in 3rd spot…

so when i drag my 1st card to the 2nd spot the card in the 2nd spot will move to the 1st spot…

Im done with the drag and drop script so what im trying to do is the changing position of the cards…

Thanks for the replies appreciate it.

I’ll post it in forum, but if yoiu guys has a solution or can help me… pls just answer here or reply…thanks

This question is too unclear! It could refer to waypoints: the object moves continuously from one spot to the next one, and when the last one is reached it goes back to the previous one, and so on. Please explain in more detail what you wanna do.

–

Don't understand what you really want to do with that.

–

hmm sorry for the unclear question. the one im trying to do here is that i have 3 cards which is horizontally arrange so my 1st card is in 1st spot, 2nd card in 2nd spot, 3rd card in 3rd spot.. so when i drag my 1st card to the 2nd spot the card in the 2nd spot will move to the 1st spot..

–

So which part do you need help with? How to drag an object? Or choosing which spot to move it to?

–

It will be on 2D, move card overtime..i already done the drag and drop part so im trying now is the question I asked above..Im really having a problem.. I also tried the Vector3.Lerp but i havent really get that..So I guess I will try and play with the Vector3.Lerp script..

–

1 Answer

1

Todo:

  • Check somhow if your 1st card is touching the 2nd card (you could do this with raycasts, coliders, position checking…find a way that matches for you)
  • As soon as the 1st card is touching the 2nd one move the second one to the position of the first one (you need an vector3 arrayor something like this. The cards could also have a script atached which stores the current possition)
  • You could move the cards using an animation or vector3.lerp (for every question you have: try to break it down in some smaller questions and then look them up in the docs or here.)
  • Check out the unity docs!