Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to get the front of a part?

Asked by 10 years ago

I've been trying to get the front of a part named "Sidewalk" using normal d but it won't work,am I doing it wrong?

How can I get the front surface of the part named sidewalk?

Front = (Vector3.FromNormalId(Enum.NormalId.Front))
----------------------------------------
Sidewalk = Instance.new("Part",workspace)
Sidewalk.Size = Vector3.new(4, 1, 37)
Sidewalk.Position  = Vector3.new(4, 1, 37)
Sidewalk.Name = "Sidewalk"
Sidewalk.Anchored = true
----------------------------------------
FrontPosition = Sidewalk.Position*Front
----------------------------------------
Point = Instance.new("Part",workspace)
Point.Position = FrontPosition
Point.Name = "Point"
Point.Anchored = true
----------------------------------------
print(FrontPosition)
1
What do you mean by "front surface"? Do you want the direction of the normal of the surface (direction pointing out that way)? Do you want to the position of the center of the surface? BlueTaslem 18071 — 10y
0
I just want the direction of the normal of the surface. kevinnight45 550 — 10y

1 answer

Log in to vote
1
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
10 years ago

A part faces front in the direction of its CFrame's lookVector property.

FrontPosition = Sidewalk.Position -- From the middle
    + Sidewalk.CFrame.lookVector * Sidewalk.Size.z / 2
    -- and a few studs out in the right direction

You should probably move Point by settings its .CFrame rather than its .Position:

Point.CFrame = CFrame.new( FrontPosition )

This will mean it won't move out of the way of other objects.

Ad

Answer this question