Jump to content
  • Advertisement
Alexander Nazarov

C# Moving tile in match-3 game smoothly or simulating physics effects

Recommended Posts

Hello. I'm pretty new in Unity and I wonder how and what should I use in Unity to create smooth and physics-like tile moving in my match-3 game?

 

 

This is example of game, where tile movements are most attractive for me 

 

Share this post


Link to post
Share on other sites
Advertisement

I think I commented on your other related thread, so I'll try chipping in here as well.

First, if you haven't already, you might find it useful to watch portions of the video you posted at reduced speed, or step by step (',' and '.' keys on YouTube, as of this writing at least). By doing so I noticed a few things:

- The falling of items is 'staggered', by which I mean that an item falls, and then the item above it starts falling a bit later, rather than all items falling at exactly the same time.

- The items seem to fall with simple acceleration, or close to it.

- When the items reach their new positions, a tight spring effect is applied, starting with a downward motion consistent with the item's previous velocity.

The next part just represents my personal inclinations. Others may recommend a different approach.

Because the behavior involves physics, it might be tempting to try to leverage Unity's physics system to implement item behavior. If it were my project though, I'd probably use analytic rather than numerical/iterative solutions, because the physics is (probably) simple enough to lend itself to that, and using analytic solutions may have some advantages. For example, you can easily determine in advance how long the animations will take, and you don't have to worry about any of the vagaries of iterative physics simulation (not that there would necessarily be any issues with something this simple).

The falling behavior can be implemented easily with so-called SUVAT equations. The spring is a little trickier. I've done that sort of thing before - I don't remember exactly how I did it, but I think I decided that a sine-wave-based animation with steadily decreasing amplitude was close enough (the initial amplitude was based on the item's ending velocity to effect a smooth transition between the falling and spring animations).

For simplicity's sake, you could start by implementing the falling behavior using analytic equations, as that part should be pretty easy, and then tackle the spring animation subsequent to that. (Another possibility would be to do the falling animation analytically and the spring animation iteratively, if that seems easier.)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!