direction = Input.GetAxis("Horizontal");
rb.velocity = new Vector2 (speed*direction, rb.velocity.y);
and it works but now when i want to launch the player in a direction using a botton the y axis work but x axis doesnt, i know because the mouvment script is making the x velocity 0 every frame but i dont know how to fix it
It sounds like perhaps you’re in over your head here and that’s not gonna be easy for anyone to solve here. The solution will NOT only be code: it will be code AND it will be other setup stuff.
I recommend doing tutorials for a game that has similar mechanics to what you are contemplating.
NOTE: there are only two steps to tutorials and / or example code:
do them perfectly, to the letter (zero typos, including punctuation and capitalization)
stop and understand each step to understand what is going on.
If you go past anything that you don’t understand, then you’re just mimicking what you saw without actually learning, essentially wasting your own time. It’s only two steps. Don’t skip either step.