Hey I have this code to rotate and launch the character in the direction of movement input. I was struggling with this until i found “GetLastMovementInputVector”.
So if this function didn’t exist how would I get the movement input vector??
I’m trying to understand as much as possible and the base movement is the standard FRotationMatrix - Yaw Rotation.
If you don’t want to use that function, you can also store the forward & right input values, turn them into unit vectors by using the float values as the corresponding axis, and combine the two vectors
Oh i have no issue with the function but I “solved” the problem I was having without understanding it.
“turn them into unit vectors by using the float values as the corresponding axis”. This is the part I don’t understand and I’ve never seen the code for it.
How do you handle the movement on user input? Via blueprints or C++? It would be more convenient to implement it in C++ if it’s not already for convenience, assuming you’re planning to work with C++ mostly.
It seems like you already got those set up then! You can forget about my comment on assigning float values to a new vector variable’s components. Why don’t you just combine those two vectors (by performing an addition) and then normalize the result to make it a unit vector in order to avoid inconsistency in magnitude between different vector combinations?
I personally do the opposite. I usually use C++ for tasks that are impossible to achieve using blueprints.
I’m brand new to programming, I’ve never worked with blueprints so blueprint tutorials don’t make sense to me and so I just went with C++ because I’ve heard it’s more efficient and ultimately more robust
Edit:
Definitely wrong lol just ran it in Unreal and my character is always launching and rotating diagonal forward left
Don’t forget to set a tolerance value in between the brackets
This new topic we’ve just opened is unrelated with your original question, but I still wanned to add that blueprints are a great way of developing even though Epic markets them as a way to help non-programmers code. They really do have superior aspects, especially in the debugging process, but they’re also objectively easier to learn than C++. In my opinion, adjusting to Unreal C++ from the pure one takes longer than getting somewhat comfortable with blueprints (and if you already know C++, that adjusting process shouldn’t even be long either, that’s how fast you can learn blueprints) because most of the nodes are pretty straightforward. Don’t get me wrong, I’m not saying abandon C++, an efficient project should use both. I just wanned to eliminate your reluctance towards blueprints.
Tolerance Value…
Could you possibly explain that like i haven’t heard of it before
Yeah i get you completely but just like I’m asking you how the individual components of “GetLastMovementInputVector” work because it does what i want but I don’t understand it. And I can follow blueprint tutorials implementing basics all day but then when I need to do something custom or more complex I have no idea what to do or the actual components that are involved.
Appreciate all the help, I have learned things You’re the first programmer I’ve talked to lol.
I’d suggest checking out the math behind the normalization calculation to have a deeper understanding if you really want. But to put it simply like you wanted, we should set a very low value as the tolerance to have the normalization work as intended with all possible vectors.
I’m glad you’re trying to learn how things actually work That’s a great thing!
I’m not on PC right now, in fact about to go to sleep, so I can’t test it myself, but it seems like issue is about that you’re not taking user input 2D Vector into account. Those vectors’s values should be manipulated by the user input X & Y values respectively. Additionally, I learned that you don’t need to manually set a tolerance value for the normalization after a quick research so that shouldn’t be the issue but like I said, I didn’t test it myself. (Plus you don’t need to normalize at all to reach your objective but I’d still recommend using it to avoid inconsistent magnitude) I didn’t use the normalize function in C++ myself, sorry for not being able to notice that earlier, but that should be all!
If you get a chance it’d be great if you could walk me through that. Again before “GetLastMovementInputVector” I was trying to figure this out. I assume there’s an easy way to get user input axis values that I’m unaware of.
You can store the values inside a variable (or variables) while making sure of constantly updating it and use it like I explained.
You’re already aware Why don’t you just use the input vector anyway? It’s not a bad practice. I just explained how it can be done without it since you were wondering but you can move on that way. I can add one more thing though, it’s currently impossible for the input vector to have a Z component other than 0 so it’s all good, but if you were to use the velocity for example in the future, keep in mind to only use it’s X & Y axis (unless you need it’s Z component for certain tasks). Similarly, you can get the X & Y components of the input vector to access the individual float values. Wanned to mention that as well.
Ok, I have been using PlayerInputComponent instead of EnhancedInputComponent up until now.
I’m going to implement it now but is that why what you’re saying just isn’t clicking for me?
Again appreciate the help