Comments (7)
Hi,
It took me time to understand how it works and I just discovered it today. It is indicated in the BezierPath script that the path between 2 points is created thanks to 4 points, 2 anchors and 2 control points which are in this order : [anchor1, control1, control2, anchor2]. There is a public function to edit the point at a certain index i. So here you just have to put the index 1 and 2 where you want to adjust the tangent !
Hope this solve your problem !
from path-creator.
I think he wants to change the point during runtime. To gather the position he wants to put the point he can still use raycast. By gathering the BezierPath (not the VertexPath !) and setting the Vector3 of the anchor to the correct index, he can create the shape he wants to.
taxi_yellow2.GetComponent<PathCreator>().bezierPath = bezierPath6; taxi_yellow2.GetComponent<PathCreator>().bezierPath.SetPoint(1,point_1,false); taxi_yellow2.GetComponent<PathCreator>().bezierPath.SetPoint(2,point_1,false);
For a 2 anchor point bezier curve, this code sets the control point of the two points at the same position.
from path-creator.
I need to change the control point positions at either end of an open path in real time. I didn't see any function for changing the position of control points in the documentation or anywhere in the code suggestions. Am I missing something?
there is no functions for this it's the Handles.FreeMoveHandle() function which is a unity editor function that makes gameobjects positioning easier it returns a Vector3 as result depending on mouse position
from path-creator.
I need to change the control point positions at either end of an open path in real time. I didn't see any function for changing the position of control points in the documentation or anywhere in the code suggestions. Am I missing something?
To change this you can use Handles.FreeMoveHandle() which is a unity editor function or use the Hanfles.PositionHandle() function which is also a function of the unity editor API and the cool thing about this function is having a transform tool when you click on the target point or object
from path-creator.
I think he wants to change the point during runtime. To gather the position he wants to put the point he can still use raycast. By gathering the BezierPath (not the VertexPath !) and setting the Vector3 of the anchor to the correct index, he can create the shape he wants to.
taxi_yellow2.GetComponent<PathCreator>().bezierPath = bezierPath6; taxi_yellow2.GetComponent<PathCreator>().bezierPath.SetPoint(1,point_1,false); taxi_yellow2.GetComponent<PathCreator>().bezierPath.SetPoint(2,point_1,false);
For a 2 anchor point bezier curve, this code sets the control point of the two points at the same position.
maybe but for this I recommend to have a bool that allows to still calculating bezier path when running because there is no interest of this only if the path changes when the game runs
from path-creator.
At each update, you can recreate a Bezier path with new list of waypoints or change only one using the previous code
from path-creator.
@YuudachiPoiii You are correct about manipulating the control points.
For anyone else trying to figure out how to manipulate control points through code, the constructor of the BezierPath won't directly let you manipulate the control points because it always defaults the control points into the "Automatic" control mode.
After you create a BezierPath via code, change ControlPointMode of your BezierPath to "Free" or "Mirrored". The index mapping of the points in a BezierPath is setup like this:
1st index = Anchor Point 1
2nd index = Control Point 1 (for Anchor 1)
3rd index = Control Point 2 (for Anchor 2)
4th index = Anchor Point 2
^ These would be the indices of the first segment of the bezier path. This structure repeats for additional segments starting with the same index the last segment ended with; so for example the indices of the points for your second segment are 4 - 7 with the 4th index = Anchor Point 2, 5th index = Control Point 3 (for Anchor 2), 6th index = Control Point 3 (for anchor 3), 7th index = Anchor Point 3.
You can check the values of the control points via GetPoint(int index), and then set the values via SetPoint(int index). You would use SetPoint() for the control point index of your choice using the index mapping structure mentioned.
from path-creator.
Related Issues (20)
- Converting Bezier point to vertex point
- "Generating a path" has a issue HOT 1
- check if the path is intersecting with itself
- Getting constant NullReferenceException s in Unity 2022.2.10 HOT 2
- Branching/Splitting a Path HOT 1
- How can I get the distance between the first point and the last point?
- Aligning an anchor's normal angle with the rotation of another object.
- Path only works if I have path GameObject selected in hierarchy HOT 2
- Constant null reference exceptions in editor HOT 5
- Anchor & Control Points HOT 1
- CalculateClosestPointOnPathData returns NaN
- Scale PathCreator game object according to screen size.
- Path is broken in between when waypoints are in straight line
- Seamless Path switch HOT 3
- Path doesn't display when selected HOT 1
- Flip Normals Set to True
- Path Creator doesn't work on unity 2022.3 HOT 1
- Getting constant NullReferenceExceptions in Unity 2022.3.28f1 HOT 1
- "Ratio" Terminology instead of "Time"
- Path is not updated before seleecting in the hierarchy
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from path-creator.