SebLague / Path-Creator

Path creation asset for Unity game development
https://assetstore.unity.com/packages/tools/utilities/b-zier-path-creator-136082
MIT License
1.8k stars 313 forks source link

Procedural path creation - unexpected flips of normal when adding first new anchor point #69

Open x70BG opened 4 years ago

x70BG commented 4 years ago

Hello, I have a simple script that generate a Bezier/Vertex path, but i have an unexpected result with normals. The normals unexpectedly flip 90 deg after appending (AddSegmentToEnd method) the first point to the first segment. After the first flip, when I append other points the normals do not flip anymore.

The first path segment is created automatically when the pathcreator object is created from a "center", as in the original BezierPath.cs constructor.

Below is the script that trigger the addition of the anchor point (apologies for the poor formatting, i can't get the new line working when embedding code). I also attached three scene screenshots:

public PathCreator pathCreator; ... Vector3 offset = Vector3.right + Vector3.forward * 0.5f; newPoint = lastAnchor + offset.normalized * segmentLenght; pathCreator.bezierPath.AddSegmentToEnd(newPoint);

image

image

image

Maclay74 commented 3 years ago

I faced the same issue, ended up with custom normal calculation based on worl's up vector.