Path-Creator | Path creation asset for Unity game development | Game Engine library

 by   SebLague C# Version: Current License: MIT

kandi X-RAY | Path-Creator Summary

Path-Creator is a C# library typically used in Gaming, Game Engine, Unity applications. Path-Creator has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can download it from GitHub.
Path creation asset for Unity game development
    Support
      Quality
        Security
          License
            Reuse
            Support
              Quality
                Security
                  License
                    Reuse

                      kandi-support Support

                        summary
                        Path-Creator has a medium active ecosystem.
                        summary
                        It has 1476 star(s) with 285 fork(s). There are 59 watchers for this library.
                        summary
                        It had no major release in the last 6 months.
                        summary
                        There are 65 open issues and 37 have been closed. On average issues are closed in 35 days. There are 10 open pull requests and 0 closed requests.
                        summary
                        It has a neutral sentiment in the developer community.
                        summary
                        The latest version of Path-Creator is current.
                        Path-Creator Support
                          Best in #Game Engine
                            Average in #Game Engine
                            Path-Creator Support
                              Best in #Game Engine
                                Average in #Game Engine

                                  kandi-Quality Quality

                                    summary
                                    Path-Creator has 0 bugs and 0 code smells.
                                    Path-Creator Quality
                                      Best in #Game Engine
                                        Average in #Game Engine
                                        Path-Creator Quality
                                          Best in #Game Engine
                                            Average in #Game Engine

                                              kandi-Security Security

                                                summary
                                                Path-Creator has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
                                                summary
                                                Path-Creator code analysis shows 0 unresolved vulnerabilities.
                                                summary
                                                There are 0 security hotspots that need review.
                                                Path-Creator Security
                                                  Best in #Game Engine
                                                    Average in #Game Engine
                                                    Path-Creator Security
                                                      Best in #Game Engine
                                                        Average in #Game Engine

                                                          kandi-License License

                                                            summary
                                                            Path-Creator is licensed under the MIT License. This license is Permissive.
                                                            summary
                                                            Permissive licenses have the least restrictions, and you can use them in most projects.
                                                            Path-Creator License
                                                              Best in #Game Engine
                                                                Average in #Game Engine
                                                                Path-Creator License
                                                                  Best in #Game Engine
                                                                    Average in #Game Engine

                                                                      kandi-Reuse Reuse

                                                                        summary
                                                                        Path-Creator releases are not available. You will need to build from source code and install.
                                                                        Path-Creator Reuse
                                                                          Best in #Game Engine
                                                                            Average in #Game Engine
                                                                            Path-Creator Reuse
                                                                              Best in #Game Engine
                                                                                Average in #Game Engine
                                                                                  Top functions reviewed by kandi - BETA
                                                                                  kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.
                                                                                  Currently covering the most popular Java, JavaScript and Python libraries. See a Sample Here
                                                                                  Get all kandi verified functions for this library.
                                                                                  Get all kandi verified functions for this library.

                                                                                  Path-Creator Key Features

                                                                                  Path creation asset for Unity game development

                                                                                  Path-Creator Examples and Code Snippets

                                                                                  No Code Snippets are available at this moment for Path-Creator.
                                                                                  Community Discussions

                                                                                  Trending Discussions on Path-Creator

                                                                                  Let a train with multiple wagons ride on a bezier path
                                                                                  chevron right

                                                                                  Trending Discussions on Path-Creator

                                                                                  QUESTION

                                                                                  Let a train with multiple wagons ride on a bezier path
                                                                                  Asked 2021-Apr-11 at 09:42

                                                                                  I use the Bezier Path Creator from the package manager to let a train ride on a predefined path. (https://assetstore.unity.com/packages/tools/utilities/b-zier-path-creator-136082)

                                                                                  Currently, I have the following code on one train unit:

                                                                                  using System.Collections;
                                                                                  using System.Collections.Generic;
                                                                                  using UnityEngine;
                                                                                  
                                                                                  public class pathFollower : MonoBehaviour
                                                                                  {
                                                                                      public PathCreator pathCreator;
                                                                                      public float speed = 5;
                                                                                      float distanceTravelled;
                                                                                      
                                                                                  
                                                                                  
                                                                                      // Update is called once per frame
                                                                                      void Update()
                                                                                      {
                                                                                  
                                                                                          distanceTravelled += speed * Time.deltaTime;
                                                                                          transform.position = pathCreator.path.GetPointAtDistance(distanceTravelled);
                                                                                          transform.rotation = pathCreator.path.GetRotationAtDistance(distanceTravelled);
                                                                                  
                                                                                      }
                                                                                  }
                                                                                  

                                                                                  This works pretty well. But when I have a train with multiple units/wagons, every wagon needs to turn after the other, not all at once.

                                                                                  I'm a little lost, how I could solve this. Any ideas?

                                                                                  Thanks!

                                                                                  ANSWER

                                                                                  Answered 2021-Apr-08 at 17:25

                                                                                  I would handle this by handling the front and back bogie of each car instead of the center of each car. And if you can assume that the track is relatively straight and that each car is going the same speed (these are the same assumption unless you want to model spring forces at each car coupling), this should work:

                                                                                  public class pathFollower : MonoBehaviour
                                                                                  {
                                                                                      public PathCreator pathCreator;
                                                                                      public float speed = 5;
                                                                                      float distanceTravelled;
                                                                                  
                                                                                      // set these appropriately in inspector and/or instantiation
                                                                                      public float startDistance = 0f;
                                                                                      public float carLength = 2f;
                                                                                  
                                                                                      // Update is called once per frame
                                                                                      void Update()
                                                                                      {
                                                                                          distanceTravelled += speed * Time.deltaTime;
                                                                                  
                                                                                          UpdateTransform();
                                                                                      }
                                                                                  
                                                                                      // May want to call this when instantiating, after startDistance & carLength are called
                                                                                      // to position it before the first call to Update
                                                                                      public void UpdateTransform()
                                                                                      {
                                                                                          Vector3 rearPos = pathCreator.path.GetPointAtDistance(startDistance + distanceTravelled);
                                                                                          Vector3 frontPos = pathCreator.path.GetPointAtDistance(startDistance + distanceTravelled 
                                                                                              + carLength);
                                                                                          
                                                                                          transform.position = 0.5f * (rearPos+frontPos); // midpoint between bogies
                                                                                          transform.LookAt(frontPos);
                                                                                      }
                                                                                      
                                                                                  }
                                                                                  

                                                                                  be sure to set the startDistance of each car so that it includes the padding between all previous cars as well as the length of all previous cars, so the caboose has startDistance=0, the 2nd to last car has startDistance=cabooseLength + padding, etc..

                                                                                  Note that this will result in different amounts of separation between the cars at different times, which is realistic behavior for a sequence of cars all moving at the same speed along a track.

                                                                                  To reiterate, if you want a constant distance between each car along curves, then you can't assume a common speed among each car.

                                                                                  Ideally, you would have a way to find all intersections among your bezier curves with the sphere centered at a given world position and radius. It's more of a math question but if you had that method, you could use that in a couple places.

                                                                                  Once, for each car to find where to put the front bogey based on the rear bogey using a sphere of radius carLength and centered at rearPos. And second, for each successive car, to find where to put the rear bogey based on the front bogy of the previous car, using a sphere of radius padding centered at the previous car's frontPos. Alternatively, you could start with the front car and work backwards. And you would need to be sure that you ignore intersections that would have the car "jump" the track and other nonsense.

                                                                                  If you did find this method, each car would want to refer to the front and/or back bogeys of its neighbors, so that would suggest putting in some additional fields.

                                                                                  Source https://stackoverflow.com/questions/66835126

                                                                                  Community Discussions, Code Snippets contain sources that include Stack Exchange Network

                                                                                  Vulnerabilities

                                                                                  No vulnerabilities reported

                                                                                  Install Path-Creator

                                                                                  You can download it from GitHub.

                                                                                  Support

                                                                                  For any new features, suggestions and bugs create an issue on GitHub. If you have any questions check and ask questions on community page Stack Overflow .
                                                                                  Find more information at:
                                                                                  Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
                                                                                  Find more libraries
                                                                                  Explore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits​
                                                                                  Save this library and start creating your kit
                                                                                  CLONE
                                                                                • HTTPS

                                                                                  https://github.com/SebLague/Path-Creator.git

                                                                                • CLI

                                                                                  gh repo clone SebLague/Path-Creator

                                                                                • sshUrl

                                                                                  git@github.com:SebLague/Path-Creator.git

                                                                                • Share this Page

                                                                                  share link

                                                                                  Explore Related Topics

                                                                                  Reuse Pre-built Kits with Path-Creator

                                                                                  Consider Popular Game Engine Libraries

                                                                                  godot

                                                                                  by godotengine

                                                                                  phaser

                                                                                  by photonstorm

                                                                                  libgdx

                                                                                  by libgdx

                                                                                  aseprite

                                                                                  by aseprite

                                                                                  Babylon.js

                                                                                  by BabylonJS

                                                                                  Try Top Libraries by SebLague

                                                                                  Digital-Logic-Sim

                                                                                  by SebLagueC#

                                                                                  Slime-Simulation

                                                                                  by SebLagueC#

                                                                                  Chess-AI

                                                                                  by SebLagueC#

                                                                                  Compare Game Engine Libraries with Highest Support

                                                                                  godot

                                                                                  by godotengine

                                                                                  Cataclysm-DDA

                                                                                  by CleverRaven

                                                                                  libgdx

                                                                                  by libgdx

                                                                                  phaser

                                                                                  by photonstorm

                                                                                  Mindustry

                                                                                  by Anuken

                                                                                  Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
                                                                                  Find more libraries
                                                                                  Explore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits​
                                                                                  Save this library and start creating your kit