Hello. I am quite new to Unity and programming in general. I am trying to make a 2D game and I’m atm dealing with a dash movement. I am having some problems managing the direction of the dash, since i want it to be even oblique, so 8 directions possible. I am trying to work with GetAxisRaw but this causes the oblique dash to be faster since it has both 1 as horizontal speed and 1 as vertical speed, so it forced me to implement an if statement for the case I do an oblique dash and decreasing the axis speed. Is there a way to get the “3dimensional” speed of the axis and not only one of the 2 independently from the other? Thank you
Hi @Otoni24
Well, the most common trick for clamping non-axis align movement when using Vectors, is to use this:
Thank you very much, this is exactly what i was looking for. I was working with Vector2 until now, this means i have to work with Vector3 axis instead of Vector2 axis?
Did you check the corresponding page for Vector2 from the very same manual?
1 Like
Oh ok, found it, Vector3 is actually for 3D. Thank you very much for your help
If you are trying to do this in a 2D game, the easiest way (which I use, as I am also a beginner), is to use a code which takes your Y axis and your X axis to move yourself up and down with the arrow keys. There are lots of different tutorials on how to do this on YouTube if you need it