Draw a line:
You should give him space as he won’t be able to figure out if you are constantly pushing him. He definitely will get irritated and ultimately your relationship can suffer. You must draw a line and let him in his safe zone when he is in that mood.
Do not take it personally:
If his mood swings, it does not mean that he hates you. We all have such phases when we want to stay alone. If he is trying to avoid you, do not take it personally and keep liking him. Make him realise that his emotions have nothing to do with your sincerity.
If you feel coldness from his side, do not get alarmed rather just stay calm and let him live his life. There can be multiple reasons behind his attitude like he has friends who are advising him to be careful. Maybe he is trying to get over his ex or maybe he is just shy and takes time to open up.
Look on the bright side:
Relationships, good or bad, give you experience to understand people and live a fruitful life. You should take this relationship as an assignment and you will see that how well it prepares you for real things. If he turns out to be your soul mate, then this relationship eventually will be very rewarding.
Make him realise:
You should make him realise that his confusing behaviour is sending mixed signals to you. However, you should ask him politely and try to put an extra effort to maintain this relationship.
You should try to know more about him as this will help you to understand his mood shifts and you will be able to settle things.