x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to get distance of two vector points?

Hello everyone, i am here to ask about get distance of two vector points.... and i know that is expecting to be simple.... but i tried so many things and nothing worked... I have an spawner box, that will get an variable random vector in area of this box, and will born an enemy in this area, and i want to get the distance of my player and this especific born area!

I already tried to get my player location and substract to my born area but didn't worked, and i tried to get the distance of my player and my spawner and substract to my born area, but didn't work to!.. to be honest i already tried so crazy things... and the only thing that i was sucess to do is to get the distance of my player and my spawner and substract this for my box expansion, in that way, i get an positive number aways that i am not in the spawner area, but i don't want that, i want the distance of my player and the especific born area of the next enemy!

If anyone can help me with this i will apreciated! (I am brazilian, so i am sorry if i wrote something wrong)

Product Version: UE 4.10
Tags:
more ▼

asked Nov 07 '16 at 10:06 AM in Blueprint Scripting

avatar image

vitor080vitor
14 4 6 9

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Hmmm, I'm not sure what your Problem is, the correct way would be

Vec1 - Vec2 -> Length

But if that doesn't work, something is wrong, try to print out the location of the enemy and estimate if your printed value is correct.

How do you get the location of the enemy? A screenshot could help.

more ▼

answered Nov 07 '16 at 10:31 AM

avatar image

Speckulous
540 22 10 36

avatar image vitor080vitor Nov 07 '16 at 10:36 AM

it still didn't work... i will take the printscreens and post here

avatar image vitor080vitor Nov 07 '16 at 10:46 AM

i am sorry about that, but my unreal is in portuguese... anyway i take the pictures. My first picture show my spawn box My second picture shows how i get the point random in this scaloned box My third picture shows how i spawn my enemies And my last image shows how i am testing if my distance is correct

(when i set the var i have 15 seconds to see where my enemy will be spawned before the box spawn it, in that way, i know that is not working)

alt textalt textalt textalt text

sem título.png (378.9 kB)
capturar.png (49.0 kB)
capturar2.png (30.5 kB)
capturar3.png (135.2 kB)
avatar image Speckulous Nov 07 '16 at 11:06 AM

To be honest I'm not understanding all the nodes in portuguese, but it looks like you get the distance between you position and "nascimento"(born location I think") and it prints 811, thats about 8 meters, isn't that the correct length?

avatar image vitor080vitor Nov 07 '16 at 11:35 AM

yes, but it don't print just 811... it prints an number different deending from my locaton, but it is not the correct distance

avatar image vitor080vitor Nov 07 '16 at 11:36 AM

"nascimento" is "birth" in english

avatar image Speckulous Nov 07 '16 at 12:22 PM

Try to print some other values like nascimento only

avatar image vitor080vitor Nov 07 '16 at 03:15 PM

it prints the next location of "nascimento", but it's random for each 15 seconds, so it's never the same number

avatar image vitor080vitor Nov 07 '16 at 04:39 PM

it is working now.... but i don't know why, i didn't change anything kkkkkk thanks

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

I hope this helps!

distance.png (64.6 kB)
more ▼

answered Nov 07 '16 at 11:35 AM

avatar image

learningOver
159 3 3 9

avatar image CriErr Nov 07 '16 at 02:37 PM

Yep, this one.

Also, if you need distance just for comparison, is it closer or further away, its better to use vector length squared, its a lot faster to compute.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question