Our son, also two has been experimenting with hitting and kicking lately. I see that it's largely a sensory experiment in how it feels, what reaction he gets, etc. Our discipline is pretty simple and it has worked, but only if done consistently.
A firm "NO" and then a simple explanation like, "it's not okay to hit or kick," or "we don't hit, that's mean."
If he acts up when we're out and about or sometimes throws a fit when we try to leave the playground, we instruct him to behave like a big boy, big boys don't act like that, etc. Then we are always sure to praise him and thank him for doing what he's told.
We have never yelled, spanked, used time out, none of that. And we try very hard to not bribe either, like if you, then you'll or giving a reward like a toy or food. I'm not a big believer in any of it and I think if you lay out consistent expectations and always enforce them no matter where or when or with who...kids start to understand what they can and cannot do-just takes a little time.
Good luck!