Download

problem with calculating distance between vectors

Hi
i am trying to generate points around player that are in certain distance from the player but not closer than certain distance.
I am generating random points in navigable radius, then calculating the distance to the player and if the distance is larger than X then blueprint goes on.

Problem i have is that even if the distance is shorter than X it is still considered as a valid point. This doesn’t make any sense. At least to me. Please advice.

Check with print string output value of vector length
or send whole BP please, this looks like it should work

What happens after the branch?

hi,
nothing important happens after the branch. i didn’t realize it may be misleading, and i am sorry about that.
here are two new screenshots. BP is somewhat modified from the first image i shown as i am trying to solve this but it’s still essentially the same code.
white circles show inner and outer radius and i need the points to be spawned between those two values.

in the viewport shot you can see points with wrong values (red) still being displayed in the are distance above 300.
same goes for the vector lengths printed on the left side of the screen. blue numbers should be = or > than 300, orange bellow 300. for some reason it’s a mess.

your help is appreciated greatly. oh, and happy new year! :slight_smile:

I solved some problems with this. It looks like you did same mistake like me.
In your branch, random point will calculate one random location, but on draw debug sphere, it will calculate another random point.
So solution is to store your calculated random point in radius to variable, and plug this variable into: -vectror length and into draw debug… I think it calculate random point on every execution node.

My test before:

and after:

IT WORKS! Thanks man!

OMG!! I am saved in the last moment of 2016! :slight_smile:

Thanks again!

addendum

to anyone who has similar problem, this thread (which i found after Name368 gave an solution, sigh ) has somewhat different approach to solving same problem but it doesn’t take navmesh into account. it still may be useful to someone.