Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
1

Vector3.FromAxis(Axis (Enum) axis)

Asked by
RSoMKC 45
6 years ago

I'm attempting to create a mining unit shot from orbit. (Using BodyPosition) When it's close enough to the surface, I want it to anchor (and do some other trippy stuff yet to be added to the script) However, I'm struggling with the Vector3.FromAxis

local body = script.Parent
local destination = Vector3.FromAxis(y (15)) --I'm struggling with figuring out what to do here.
local closeEnough = 1

while (body.Position - destination).magnitude > closeEnough do
    wait(0.1)
end

if (body.Position - destination).magnitude > closeEnough then do
    body.Anchored = true
end
end

I have no idea if the script will work at all, but this is the current roadblock I'm facing. Anyone know what I'm supposed to put here?

1 answer

Log in to vote
3
Answered by
Merely 2117 Moderation Voter Community Moderator
6 years ago

According to the wiki, Vector3.FromAxis has one argument, with a type of Enum.Axis

The options for the enum are: X, Y, and Z.

Here's an example of how to use it.

Vector3.FromAxis(Enum.Axis.Y)

Some other changes needed for your script: - Line 9 doesn't need a 'do' at the end, you only need that for loops (while, for, etc). - The expression on line 9 is going to be false every time because you waited until the distance was close enough inside the while loop.

It looks like you're trying to detect the height difference between the body and the destination. In that case, you should discount the x and z values when calculating the distance, and just use the y-values.

local distance = math.abs(body.Position.Y - destination.Y)
0
This came close enough. However I ended up using: if (script.Parent.Position.Y <= 25) then RSoMKC 45 — 6y
Ad

Answer this question