#vectors
1 messages · Page 1 of 1 (latest)
again I am not trying to solve my problem, I am trying to understand why my understanding is wrong
obviously I want to solve my problem but I can't solve it myself if you just tell me the answer
Based on the code you've shown me, the video doesn't make sense
I would expect the squares to move by exactly 1 meter away from their origin point when the vector is normalized
public Transform avoidThis;
private Vector3 origin;
// Start is called before the first frame update
void Start()
{
origin = transform.position;
}
// Update is called once per frame
void Update()
{
Avoid();
}
private void Avoid()
{
Vector3 direction = avoidThis.position - origin;
//float dist = direction.magnitude;
direction.Normalize();
transform.position = origin + direction;
}```
thats literally all of it
and when you move the avoidThis transform around, the squares move in that non-uniform way?
where they move further if they're closer
when I dont normalize the vector, all of them move the exact same distance in the exact same direction
when I do normalize the vector, they all move different directions relative to the object
why is this
to make this easier to visualize, can you add this to Update?
Debug.DrawLine(transform.position, origin);
sure 1 sec
I think there might be a bit of an illusion going on here
And make sure that the sphere isn't above or below the squares
3 dimensionally its moving up, that makes sense, but this is not my problem and not my question
It looks like it's below the squares.
it is, but again this is not my question and not my problem
The vertical offset is making it harder to understand what's happening
humor me and line it up vertically
it will make things easier to see
oh yeah, and the perspective camera is also going to mess things up a little
set the scene view to orthographic and view it from the top
if I dont normalize it, why do they all move perfectly in unison?
We'll get there.
okay
look at the normalized version with an ortho camera from above first
okay, so see how every one of those green lines has the same length?
they just point in different directions
Right
but normalizing has nothing to do with directions? So why is normalizing changing its direction
you see a non-uniform grid because each square gets pushed by 1 meter in a different direction
exactly 1 meter, always
also, is the last column of squares on the right a little bit off?
i noticed the gap is smaller in all of these scerenshots
yeah I positioned them manually its not a perfect grid
notice how all four of these squares have the same gap between them
which is unrelated and unimportant but does make it harder to debug I guess
they're getting pushed in the same direction, by the same amount
so that line doesn't get distorted
yes 🤔
meanwhile, this line is skewed all over
because they're getting pushed in very different directions
(again, by exactly 1 meter, always)
yes 🤔
like here they're all pushed exactly 1 meter away directly away from the position
so that's why, when the vector is normalized, you get this sort of varying effect
I dont understand why normalizing changes that though
because if it wasnt normalized, the orb in this exact position, the entire grid wouldnt be pushed away from that spot
the entire grid moves as a giant single object
so, switch it back to non-normalized
and then show a screenshot with the sphere in the same sort of position
put it somewhere so that it's sitting inside of the resulting grid
so, when not normalized
you're moving each square based on how far away the square is
the further away the square is, the further it moves
imagine this in 1D
🤔
you have a square at 1, 2, 3, 4, 5, ...
and you put the sphere at 0
if you normalize the vectors, the squares wind up at 2, 3, 4, 5, 6, ...
each one moves to the right by 1
if you don't normalize the vectors, the squares wind up at 2, 4, 6, 8, 10, ...
each one moves to the right by how far to the right it was
I am not getting it at all, I will just describe what I WANT and you tell me why I'm not already getting that 🤔
What I want to do is to push away from that position, but only within a clamped distance relative to how close that position is to the thing.
So like they don't move at all until the position is within X of it, and then they push away from that position, multiplied by the distance
(I know none of my code does any of that yet because I havent gotten there because it wasnt behaving the way I expected)
I know to get this I have to multiply by distance at some point
I'm starting to get extremely stressed out and go into crisis because I just dont understand and I need to understand and im wasting company time being a fucking stupid idiot who can't solve the most basic vector math
how the fuck did I ever get hired when I can barely glue two bricks together 😓
but all of this is unrelated
Put the sphere exactly on top of the top-left square (before you enter play mode). See how the column of squares move when you enable and disable the normalization.
It will re-create this example.
visually: I want to push the object in the direction (red) by the magnitude of its distance (gradient)
so if its at <distance greater than gradient> it gets pushed zero
so to do that the magnitude must be clamped between 1 and 0 over a range of <length>
and then pushed in <direction>
but... <vector shit I dont understand here>
i want you to understand what's happening here first.
sure
so, set it up like i described
then enter play mode and turn normalization on and off
no, just position it exactly on top of the top-left square
leave it in place as you turn normalization on and off
oh okay sure
the closest one is jank because its moving 1 whole unit away and I cant get it perfectyly on top
yeah, it'll be weird
normalization cause very violent movements at very short ranges, since a tiny move is a big change in direction
so, can you see how this relates to the 1D example up here?
Not really?
Like, I dont see, I dont understand
I am not sure what I am supposed to be seeing and understanding
let's say the sphere is at 0
and just look at the one column on the left
In the left image, the squares are moving based on how far away they are from the sphere
if a square is at 4, then it moves by 4
if a square is at 0, then it moves by 0
In the right image, the squares are moving by 1, always
every square moves down by the same distance, because they're always moving by 1
this is also why that top-left square goes off at a funky angle
it must move by 1
but in the not normalized version, they all move by exactly the same distance gap, just larger
how is the normalized version any different from not normalized but multiplied down smaller
because in the normalized version, each square moves by the same amount
in the non-normalized version, they move by different amounts
The bottom-left square is moving way further than the top-left
You're doubling their positions.
It's like scaling up the squares, where the origin is the sphere
so Ishould multiply by 0.5?
i'm strictly explaining why you're getting the behavior that you're getting
Right
I'm sorry im dumb as shit, you are doing your best and I am just not comprehending
how far apart are these numbers?
right, and they're evenly spaced
why are the values not exponential
before normalizing I would expect that each one would get exponentially further away
because each one IS further away
2, 4, 6
right.
they're still evenly spaced, see?
they're just further apart
the squares are at 1, 2, and 3
the sphere is at 0
now, move the sphere to -1
and add the distance from the sphere to each of the numbers
1 and -1 have a distance of 2
so 1 + 2 -> 3
2 and -1 have a distance of 3
I just don't understand, I am reading the words you are saying but its not forming any kind of comprehension. Its like you are describing color and I am blind andhave never seen color before
I'm just getting more frustrated because you are trying so hard and I just don't get it, which only makes it harder to comprehend
I'm the problem here, I need a break maybe and then will read this when I am not borderline crisis
sure. take a break.
it's good to let new ideas stew for a bit
Thank you for your help, I know I am frustratingly thick
it's alright
ontop of all this I used to be really good at this but its like flowers for algernon, it only makes it worse that I know that I used to know
and no longer do
(i stopped coding for a few years)
and its very much not a fuckin bycycle
i no longer recall how to do anything, only things that exist like interfaces and.. like I can't even remember other concepts