How to move an actor to vectorA - 200 units towards vector B? (Picture included.)
Thats pretty easy vector math, just substract B from A, normalize it and multiply it by the desired distance. You also could use the Lerp(vector) node, divide the desired distance by the distance between A and B and use this value as Alpha.
You will need vector math very often when working on games so you may want to improve you skills in that field when you want to develop games.
(I admit, I’m still studying vector math. I’ve been learning as I go along making games, I find it more meaningful this way, whereas my math book often teaches without context. (Maybe I need a better book, idk. If there is a book that teaches math regarding video game usage, that would be perfect for me, lol.)
The methods you gave me didn’t do what I want. Perhaps I overlooked something, but I’m pretty sure it’s because I forgot to mention something:
The position of vectorB relative to vectorA could be absolutely anything. Playing with your code, I could only manage to set the actor a certain percentage between A and B. But I want the actor to always be exactly 200 units away from A, in the direction of B, despite how far away they are from one another.
I’m sorry if this is still an easy and/or stupid question, (I know it probably is,) but that’s a big part of what this site is for.
Don’t worry, vector math is pretty simple, you just need to know a few basics and then you can do a lot with that.
To solve your problem you need to find a Vector from A pointing towards B with the length of 200. B - A gives the direction from A to B, when you normalize that vector it still points in the direction of B but has the length of 1, then you just need to multiply it with 200 to get a vector with that length.
Than you can add this vector to A to get the location Betweeen A and B with the distance 200.
This is how it looks in BP but it makes sense to understand whats going on:
Thanks, mate! It works perfectly!
And kudos for explaining it too! You did a really good job! ^^
Hi ! I’ve got a similar question and I think you can help me I created a socket called HandLeftSocket to my character and I want to move it to a specific location called “GraberLocation” by using SetActorLocation. I thought that substracting [Origin Vector] by [Destination Vector] would work, but not at all. Can you explain me how to do that ? Thanks !