Do you just want to find a point that makes a 90 degree angle between the models? There are many points which will do that. To get just one point you could choose a direction, maybe the way Model 1 is facing?
I don’t think I understand… here’s how you could get the point in the first image (not sure if it’s what you meant)
local line1:Vector2 -- one end of the line segment
local line2:Vector2 -- other end of the line segment
Vector2.new(line1.X, line2.Y) -- the point you're looking for
what im looking for is the 90 degree point located between model 1 and 2, to get its position we must try to get X or Y length then use the pythagorean triple or atleast A/B angle in degree
what im looking for is the X/Y length or A/B in degree for the perpendicular point position, is there any math function that could returns those values?
Unless you specify atleast one of the angles (A or B) then there is an infinite number of possible solutions. Perhaps it would be better if you explained the bigger problem that you are trying to solve?
im trying to move all the model(which is an npc or player’s character) to a place that the center is the character, the other npc will keep the same distance before the moving event starts, just like chosing all of them and move with the ‘move tool’ inside of the studio without using the weld constraint
So basically, if the player moves or rotates around, all the models should follow the player’s rotation and movement?
In that case, you’re better off doing local offsetCF = modelCF:ToObjectSpace(playerCF) as the offset between the player and the model’s pivot point, and each time the player moves doing model:PivotTo(offsetCF:ToWorldSpace(playerCF)).
the model moving should works like this move tool in studio, selecting muti models and moving them with different position but will have the same distance to others
Edit: Actually, you can get and subtract/work with the individual axis of a vector. Like do vector.y and boom, i think.
If it helps, a triangle’s angles add up to 180 and you can get the degree for an angle with arcsin() math function. It’s arc or inverse trig functions that get the angle.
I believe you can simply subtract the end and start vectors to get the non-dotted line.
To get a right angle from a vector, you should need to rotate the vector, or make it point, 90% from where it’s original vector is.
With the look vector that’s easy, you can get the vector.right or up or whatever and then find a magnitude for the vector to multiply it by to reach whatever the other angle is.
That or offset the current position vector first, and then go to the original position.
but can you explain further for the right angle of the vector? or atleast for the x/y length for the triangle, the only position i got is the player’s char and the npc world pivot which is marked with an straight line(non dotted line)
edit : i think ill have to make the other angle inside of the triangle 45 degree to make it easier for this function
It’s a step in the right direction, I think. The Docs talk about relative position, so that’d be a good area too. It’s basically an offset, but relative, and specific.
In order to get either x1 or x2 it’ll depend on what the starting position would be. Lets say we have a starting position of Point A (2,2) and end point of Point B (4,3). To get the perpendicular position X value you would first do 2 - 4 = -2, then subtract it with Point A’s X (2), so 2 + 2 = 4 = X value (subtracting negative makes it positive, thus the adding of 2). And we do the same thing for the Y value, 2 - 3 = -1 → 2 + 1 = 3 = Y value. Thus we get the perpendicular position of (4, 3) which is [not] Point x2.
If Point 2 was the starting position and Point 1 was the end position and we did the same math from above, we’ll get Point x1 as the perpendicular position.
Since you’re using a Model’s Position, all you’ll have to do is Model1.Position - (Model1.Position - Model2.Position) then you can just get the X and Z values then boom you’ll have the Perpendicular position in a Vector2. And Vector3. If you wanted in 3D space.
[Edit] I was half correct. Luckily Reditect fixed it for me. Basically Pos1-Pos2 = newPos then subtract Pos1 with newPos.X
local Pos1 = A Position
local Pos2 = A Position
local Direction = (Pos1 - Pos2)
local PerpenPos = Pos1-Vector3.new(Direction.X,0,0)
Though this only gives the perpendicular position in a sort of 2D plane. So not sure if it’ll work for your game
The original post seemed simple, but the more replies I read the more complicated it got
I don’t think I understand what’s going on, but here is what I think is happening:
You want to make one model basically the origin, so the 2d coordinate plane is relative to that model, then you want the position of another model on the said coordinate plane.
You should do local relativeCF : CFrame = Model1:GetPivot().CFrame:ToObjectSpace(Victim:GetPivot) here is how that should work
To find the side length of the triangle in your diagram, you can use relativeCF.X or relativeCF.Y, respectively.
In the event you want to solve your diagram manually and inefficiently for whatever reason, you can find the difference vector local difference : Vector3 = Victim:GetPivot().Position - Model1:GetPiviot().Position you can then convert into Vector2, and find the angle between them. (after you obtain the angle, the sides of the triangles can be figured out quite easily since we know the hypotneuse, we can use sine and cosine.)