Code Monkey home page Code Monkey logo

path-creator's Introduction

path-creator's People

Contributors

keenanwoodall avatar lunacapra avatar mrpropellers avatar pschraut avatar seblague avatar zaikman avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

path-creator's Issues

Branching and Merging [Proposal]

Hi there Seb and Keenan,

The ability to create a new path attached to an old path (branch) and join an existing path (merge) would be a really cool feature that would add a lot of value to this package. It could easily turn into an implementation nightmare if not properly constrained, but I think I have an approach that is simple enough to avoid increasing the complexity too much. I've already forked the project, and am working on implementing this now. This issue serves both as a design document and a request for feedback on the proposed additions.

A branch can be achieved manually by creating a new path and copying anchor/control pair from the original path into the first anchor/control pair for the new path. Similarly, a merge can be achieved by doing the same with the last anchor/control pair. Here's an example of the result.

Original Path:
BranchingPaths2
Branching and Merging path:
BranchingPaths1

The manual approach could be automated by allowing an anchor on one curve to reference an anchor on a different curve by providing the PathCreator and the index of the target anchor. Each anchor can only reference one other anchor (one parent), but each anchor might be the target of many references (many children). Each BezierPath now needs to keep track of each anchor's parent and children. Control points do not need to be kept track of like this because they are referenced implicitly by the anchors.

List<Tuple<BezierPath, int>> anchorsParent;
List<List<Tuple<BezierPath, int>>> anchorsChildren;

It would also be good to keep track of the relationships between BezierPaths:

Dictionary<BezierPath, Hashset<int>> pathIsParentAtAnchor;
Dictionary<BezierPath, Hashset<int>> pathIsChildAtAnchor;

One potential problem with this approach is that anchor indexes are not guaranteed to stay constant. Each child anchor needs to know when its parent path adds, splits, or removes a segment. Each parent anchor also needs to know when each child adds, splits, or removes a segment.

public event System.Action<BezierPath, int> OnAnchorAdded;
public event System.Action<BezierPath, int> OnAnchorRemoved;

When either of these events is triggered, the receiver should ensure that they they are referencing the same anchor they were before the event, or that they remove the reference if the anchor was removed. Changes can occur in one of three locations: upstream, downstream, or on each referenced index. An event downstream (higher index) of an anchor will not affect the anchor index and an event downstream (lower index) of an anchor will offset the anchor index by one. If an addition event coincides with a referenced anchor, increment its index. If a removal event coincides with a referenced anchor then remove all of the references to it.

Is possible to use this with rigidbodies?

Hey guys, how are you?

I'm trying to implement path walks for some npc in my game. I really don't like to much navmeshagent, I think it sucks actually. So I decided to take the harder but better way.
I am thinking if Path Creator is capable of moving as a rigid body, respecting the colliders and gravity it can be finding along the path.
Thanks!

Normals on 2D line cause unwanted rotation

Screen Shot 2019-09-22 at 8 22 10 AM

This is the 3D scene view of the moving object, it's rotation is set to 0 on every axis by default. The normals of the line cause it to rotate on the X and Y axis, making it somewhat useless for 2D projects. Is there any way to make the normals face in the direction the line is going in 2D? Hopefully I'm just doing something wrong.

Coordinates of Points in Inspector [Improvement]

As is, when I click on a point, I have no way of knowing its coordinates.

Could this be integrated with the Unity Inspector, so that these points can be moved around by changing the x, y, z coordinates in the Inspector (just like one can for everything else in Unity)?

Playmaker Actions

Hi.

Thanks for the great spline tool. I have had some request for playmaker actions, so I have gone ahead and started making some. You can find them here: https://github.com/dumbgamedev/Path-Creator-PlaymakerActions

They are released under the MIT license.

Could you add a link to your description page or documentation, so that more users can find them?

Thank you 👍

Add speed modifier to path points

First of all, thanks for the wonderful work, I am definitely gonna use it in the future even just to see these smooth movements maybe with a particle system.

Just some suggestions on some improvements:

  • It would be cool if every points would have a certain speed modifier, so that the object could slow down or get faster the closer it is to the node. The speed could be interpolated between one node and the next one and a weight of each node's speed could tell how strong is the acceleration/deceleration to that point.
  • Another way of doing this would be some sort of speed modulation according to how steep a hill his (on the x-y plane) or how tight the curve is (on x-z plane). For instance, a curve would force the object to slow down, and this is given by how curved the path is a that point given the angular velocity (just like you would slow down while driving on a very tight turn). This is could be achieved by using the same idea as before, each point would get a speed modifier, but this time would be computed according to the curve between one point and the next one. The sampling rate (angle error in the vertex path) would give different results obviously but it would allow for a single modular implementation of the path's points speed.

Other suggestions on it would be any kind of parameter that can be interpolated like color, materials, scale.

Change from one path to another

Hello everyone,

I face a problem while I try to make my game object switch from one path to another using BoxCollider.

Here is some of the code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using PathCreation;

public class LandingOver : MonoBehaviour
{

public PathCreator Path2;

//Before this, my gameObject is following another path, let's call it Path1.
void OnTriggerEnter(Collider other)
{

    other.gameObject.GetComponent<Follower>().pathCreator = Path2;
    other.gameObject.GetComponent<Follower>().speed = 2f;


}

}

Unfortunately the gameObject switch from Path1 to Path2 but begin from the middle of Path2, not from the begining. So the transition is a fail. How to prevent my gameObject to "jump" ignoring a large part of Path2 ?

Do you have any other method to suggest ?

Thank you in advance for your time and consideration,

Francis

length of a path?

Hey,
first thanks for you work, works great!!!

Is it possible to some how detect if a object has fully travelled the path?
I am looking for a way to count how many cycles an object travelled the path. I am using a non-looping setup.

I was thinking of doing it using the total path length and the travelled distance.
Is there a way to measure a paths length during run-time?

My first idea was to calculate the distance between all vertices of the vertex path.
Any more elegant way?

regards

Thicker Lines [Improvement]

Could you add an option to make the lines thicker, especially the normals?

As is, they are almost invisible when zoomed even slightly out.

PS: I am asking for thickness, not length (which you already have).

path.GetClosest functions extremely slower compared to previous versions

Hello there! First of all thanks a ton for this great tool.

I've upgraded from a previous version (1.0 or 1.1, not sure) via the asset store and I've noticed that GetClosestDistanceAlongPath is about 10-15 times slower compared to the previous implementation.

For many users this change might be negligible but in my use case I'm sampling the value of the curve over a grid hundreds of times.
What previously took around ~100 ms now jumped to ~1250 ms.

This is caused by the new world to local transformation enforced in GetPoint() for example.
While this can be helpful for many, it would be good to allow skipping the transformation when not necessary (for example my curves are already frozen at Pos=000, Rot=000, Scale=111) using a bool parameter transformToWorldSpace with a default value of true.

Adding more than 5 point sometimes cause render error

Hi, thanks for great assets, but I encounter an issue that when I adding more point it causing the mesh render error like the image. I use open path not a closed path. When this error is occur, I adding more point is useless the mesh is not updating anymore.

screen shot 2019-02-14 at 9 36 54 am

screen shot 2019-02-14 at 9 38 07 am

How check end of path

I'm developing a race car sims, i need to check end of path (race start line), it's possibile with path creator object or i need a collider object to solve the problem?

Freeze Editor with Canvas Render Mode Camera

I got bad editor performance when using Path Creator inside Canvas. This canvas uses render mode Screen Space - Camera. Adding a new point make the performance worse.
I'm using Unity 2019.1.6.

Paths are always in world space?

It appears that moving a GameObject parent containing GameObject with a path has no affect on the path. Are there any plans to fix this or is there a work-around? For procedurally generated levels or placing paths in prefabs, this seems like a big problem.

Camera + Mouse Look [Question]

How would this work when the object following the path is a camera?

I would like to have a camera move along the path, but also allow the player to control what direction the camera is looking into by using their mouse (Mouse Look).

How would you implement that?

Feature - Custom Mesh Support.

So I know the mesh has a generate function, however adding the ability to use your own mesh and materials on the Road example would be very helpful for those looking for a free road tool replacement.

I may make a pull request in the future if I get it working properly.

Additional Example Scripts

Hi,

Here are three more example script that people may find helpful.

  1. draws a line renderer according to the path
  2. object spawner along the path.
  3. set agent position according to percent, rather than by speed.

Thanks!
Eric

ExampleScripts.zip

VertexPath.GetPointAtTime(1.0f) return wrong answer

VertexPath.GetPointAtTime(1.0f) returns the start of the path instead of the end
while VertexPath.GetPointAtTime(0.9999f) is working correctly, and returns a point which is very near to the end of the curve.

I have the same result with VertexPath.GetPointAtDistance(VertexPath.length) which is not working either.

Help - Path not visible when clicking on the GameObject

Hello,

Recently on my main project when i create a pathcreator on a newly created GameObject the path isn't visible when the object is selected. This wasn't the case before and if i try to do the exact same thing on a new unity project it does work as expected.

Here is what i checked;

  • All the properties inside the inspector and in display and global display options are exactly the same
  • All gizmoz are enabled
  • Checked if there is pathcreator settings in the top menu (File, Edit, Assets ... ) but didn't find anything related to it

I can't find the difference between the two project so that it makes the path disapear. I spent 2 days searching for it.

I would thank anyone trying to help me. Here is also a .mp4 inside the zip folder to demonstrate the problem.

IBcIs91mvp.zip

How to calculate the normal of a point.

// First reflection
Vector3 offset = (localPoints[i] - localPoints[i - 1]);
float sqrDst = offset.sqrMagnitude;
Vector3 r = lastRotationAxis - offset * 2 / sqrDst * Vector3.Dot (offset, lastRotationAxis);
Vector3 t = localTangents[i - 1] - offset * 2 / sqrDst * Vector3.Dot(offset, localTangents[i - 1]);

// Second reflection
Vector3 v2 = localTangents[i] - t;
float c2 = Vector3.Dot (v2, v2);
Vector3 finalRot = r - v2 * 2 / c2 * Vector3.Dot (v2, r);
Vector3 n = Vector3.Cross (finalRot, localTangents[i]).normalized;
localNormals[i] = n;
lastRotationAxis = finalRot;

What does “first reflection” and “second reflection” mean?

Scaling in editor scales every axis, even if only one changed

Using 1.2 from GitHub.

Replication: create a path, scale it in either x, y or z using either the Transform component or tool, and observe that the whole path scales in the scene (x AND y AND z) even if only one of those axis is scaled in the transform.

The video shows this working as intended, where the path will stretch in the given axis (only) rather than scaling the whole thing.

Add Meshcollider to RoadMeshCreator

I added the option to add a Meshcollider to the RoadMeshCreator.

Problem: You could simply add a meshcollider in the Unity editor. But if you do that, the meshcollider does not get updated when the mesh is altered by changing the path.

Solution: The skript attached takes care of updateing the meshcollider. Its very simple. Just enable the Meshcollider checkbox of the RoadMeshCreator Component.

I thought this feature could be intersing for others or even for trunk.
RoadMeshCreator.cs.zip

Angle always point up

Is there a way to make it so the angle always points up? I am able to go through each point in the path and manually rotate it to get it to face upwards, but this takes a long time and it would be nice if I could just make the angle at all points always pointing up.

In other words... no banking, follower just always stays upright, doesn't tilt left or right

pointup

Point Position Moving

PointsMoving

As you can see in this debug log the selected point is slowly moving on it's own by .00003 in the Y and Z coordinates. The path was generated using the example generate path script and an array of vertices. The currentPosition and newPosition are reading the same change and staying equal so I'm not sure what could be causing it to slowly drift like that but it is sure slowing Unity to a crawl. Any thoughts what could be causing this?

Copying normal anchor angle value from another anchor

Hi. Thank for the asset.
I'have encountered an issue. When I try to set anchor angle to first point of my new BezierPath from the last point of previous Bezier Path, the angles appears to be mirrored.
Here is the angle of last point of Bezier 1
default
And here is the angle of first point of Bezier 2 after setting the value from Bezier 1 angle
default
My code is:

path.bezierPath.SetAnchorNormalAngle(0, ZeroAngle());
float ZeroAngle()
{
    return prevPath.bezierPath.GetAnchorNormalAngle(prevPath.bezierPath.NumAnchorPoints - 1);
}

Debug shows same values for angles.
Please help me with this issue.
Thank you.

Inaccurate Rotation calculation via GetRotationAtDistance

Hello, at first, thank you so much for this asset, it's amazing!
But I have an issue with GetRotationAtDistance function. It returns slightly inaccurate values.
Here is an example:

Rotation_issue

I just instantiate objects in the right distance, and they have incorrect rotation in Z axis.

It would be great if you fixed it or tell me what I'm doing wrong :)
Maybe I'm missing something.

Straight Lines

What's the best way to just create a straight line but still have it go through the Path Creator system?

Position Type-In for Path Points

I was curious if there were any plans to support manual type-in of path point positions? Specifically the start and end points for several paths we're using need to be set to a specific value.

Path Creator ignores its gameobject's transform changes

Once you create the path, it never gets updated with the changes made on the gamobject's tranform. Normally, I would expect the changes on the game object's or its parents' transform changes to affect the path itself too. So it would be better if the created path's points were relative to the game object.

I think the tool is almost perfect and thank you for sharing it.

Slowdown when calculating normals to draw

Hey Sebastian -

Great tool, thanks for sharing it!

When making a long path (many hundreds of units) the number of normals to calculate and draw was getting out of hand and slowing down the editor profoundly. Maybe consider not drawing each normal or showing every N where it's not doing too many?

for (int i = 0; i < normalsVertexPath.NumPoints; i++) { normalLines[i * 2] = normalsVertexPath.GetPoint (i); normalLines[i * 2 + 1] = normalsVertexPath.GetPoint (i) + normalsVertexPath.GetNormal (i) * globalDisplaySettings.normalsLength; }

Moving along Path with timeline

I was Wondering if it is possible to use the motion path controlled by timeline editor. It should be awesome for some movie scenes.

Path not updated when game launches

Hi! First of all thanks for this awesome tool it saved me a lot of time. Here's my issue :

I have a path creator and a roadMeshRenderer attached to a gameobject. I also have a script (separate game object) that gives a random position to a random number of points situated on the path when the game launches. For now it is working (the path is updated) only if I execute the game and, within the hierarchy, select the path creator component.

The problem here is that when I build the game I cannot access the hierarchy to update manually so how can I call some sort of UpdatePath() in an initialization method?

Thanks in advance :)

How do I clear a path? Possible bug?

I need to load points from a script. Firstly I want to clear my path.
I tried to override all points via code:

var points = new Vector2[pathCreator.bezierPath.NumPoints];
for (var i = 0; i < pathCreator.bezierPath.NumPoints; i++) { points[i] = pathCreator.bezierPath.GetPoint(i); }
points[0] = Vector3.zero; // Some new value :)

var bezierPath = new BezierPath(points, false, PathSpace.xy);
pathCreator.bezierPath = bezierPath;

And I it doubled my Bezier points. If I run that code more times I have x4, x8 point count. I expect the same curve as it was before because with that code I don't change nothing.
And the second question is how to clear bezier points before settin' new values?
How to change a position of just one point of the Bezier path?

Missing fragments of road with strange GetRotation values when using RoadPathCreator

Hi Sebastian. Missing fragments of road when using RoadPathCreator. I have no idea why this happens. Normals hasn't been changed from code.

My player GameObject gets rotation (-1.06, 29.632, 4.346) at point (384.7814, 20.70795, 1509.418) and than sudden the player object rotations changes to (-1.057, 29.495, 89.72201) at point (386.1715, 20.76006, 1511.858).

Im using this code to position player:

player.transform.position = roadPath.GetPointAtTime(delta, EndOfPathInstruction.Stop);
player.transform.rotation =  roadPath.GetRotation(delta, EndOfPathInstruction.Stop) * Quaternion.Euler(0, 0, 90);

Can you check what is wrong with path creator?
I can send you my unity project if you like.

My points are:

public Vector3[] pathPoints = new Vector3[] {
        new Vector3(0.0f, 0.0f, 0.0f),
        new Vector3(0.0f, 0.0f, 41.7f),
        new Vector3(0.0f, 0.0f, 83.3f),
        new Vector3(3.6f, 0.0f, 124.8f),
        new Vector3(3.6f, 0.0f, 166.5f),
        new Vector3(3.6f, 0.0f, 208.2f),
        new Vector3(3.6f, 0.0f, 249.8f),
        new Vector3(7.2f, -3.6f, 291.2f),
        new Vector3(14.4f, -10.9f, 331.6f),
        new Vector3(25.0f, -21.6f, 370.4f),
        new Vector3(35.7f, -28.7f, 410.1f),
        new Vector3(46.5f, -32.3f, 450.2f),
        new Vector3(57.2f, -32.2f, 490.4f),
        new Vector3(64.3f, -28.6f, 531.3f),
        new Vector3(71.2f, -21.4f, 571.8f),
        new Vector3(74.2f, -10.7f, 611.9f),
        new Vector3(77.1f, 3.4f, 651.0f),
        new Vector3(76.8f, 10.3f, 692.1f),
        new Vector3(80.6f, 10.2f, 733.6f),
        new Vector3(91.5f, 10.5f, 773.8f),
        new Vector3(109.3f, 11.2f, 811.5f),
        new Vector3(130.2f, 12.0f, 847.5f),
        new Vector3(147.9f, 12.7f, 885.2f),
        new Vector3(162.3f, 13.2f, 924.4f),
        new Vector3(176.7f, 13.6f, 963.5f),
        new Vector3(187.6f, 13.9f, 1003.7f),
        new Vector3(195.0f, 14.0f, 1044.7f),
        new Vector3(202.4f, 14.1f, 1085.7f),
        new Vector3(206.1f, 14.1f, 1127.2f),
        new Vector3(209.9f, 14.0f, 1168.7f),
        new Vector3(210.1f, 13.7f, 1210.3f),
        new Vector3(213.9f, 13.6f, 1251.8f),
        new Vector3(224.8f, 13.9f, 1292.0f),
        new Vector3(245.7f, 14.7f, 1328.1f),
        new Vector3(275.3f, 16.1f, 1357.4f),
        new Vector3(302.1f, 17.3f, 1389.2f),
        new Vector3(326.1f, 18.3f, 1423.3f),
        new Vector3(350.1f, 19.3f, 1457.3f),
        new Vector3(374.1f, 20.3f, 1491.4f),
        new Vector3(395.0f, 21.1f, 1527.4f),
        new Vector3(416.0f, 22.0f, 1563.4f),
        new Vector3(436.9f, 22.8f, 1599.4f),
        new Vector3(457.9f, 23.7f, 1635.4f),
        new Vector3(472.2f, 24.2f, 1674.5f),
        new Vector3(479.6f, 24.3f, 1715.6f),
        new Vector3(479.8f, 24.0f, 1757.2f),
        new Vector3(479.9f, 23.7f, 1798.9f),
        new Vector3(480.1f, 23.4f, 1840.6f),
        new Vector3(482.5f, 19.1f, 2482.2f),
        new Vector3(482.6f, 18.9f, 2523.9f),
        new Vector3(482.8f, 18.6f, 2565.5f),
        new Vector3(483.0f, 18.3f, 2607.2f),
        new Vector3(483.1f, 18.0f, 2648.9f),
        new Vector3(483.3f, 17.7f, 2690.5f)
    };

path_creator_issue_1

Best regards
Peter

Path Follow Rotation inaccurate

So I'm building a procedural path using the tool and I have a test gameObject following the path and a sphere mesh as children with a script that changes its local x position. However sometimes the sphere goes through the path or flies above (only when local x is not 0 for a certain amount of time).
How can I fix that?
Thanks in advance!

2D paths do not snap to the plane of the parent Transform

When the space specified is on a 2-dimensional plane, the path snaps to the global 0 coordinate for the axis that is being ignored, rather than the local coordinate of the parent object. This means that if a user wants to create a path that is constrained to a 2-dimensional plane, they are obliged to do so in global space and then switch to 3d coordinates to move the path, rather than building the path in the parent transform's coordinate space. It also means the path jumps around quite a lot when the parent game object is far from the scene origin and a users is switching between path spaces.

Editing control points in script

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.