Giter Site home page Giter Site logo

com.retrover.path2d's Introduction

Retroever.Path2d

2d curved path movement project for Unity

This solution will allow you to build a path from bezier curves, then create a client and move it along the path.

โญ The project has an OOP architecture, which makes it easy to integrate.

How to start

  1. Add an empty object to the scene. Add the "CurvedPath" script to it.
  2. Create a curve using this component.
  3. Create another object with the "ExamplePathClient" script. Specify in it the curve that you created before.
  4. ???
  5. Press play and have profit ๐Ÿ˜Ž

Installation

Make sure you have standalone Git installed first.

alt text

And paste this: https://github.com/YooPita/com.retrover.path2d.git

Or just copy the repository to your project files.

Instruction

Path

1. Create a List of Curve Points

var points = new List<CurvePoint>();

2. Fill it with dots

You need to specify only the right handle. The left handle is a reflection of the right handle.

CurvePoint(Vector2 position, Vector2 rightHandle)

3. Create a path

Path(List<CurvePoint> points, int precision, bool isLoop)

  • precision - how many points will be set on the curve. The curve consists of segments in order to simplify the search.
  • isLoop - is the path closed.

Client

1. Create a client

Create a class and inherit from an interface IPathClient.

In method UpdatePosition(PathPosition position), the client gets its position when it's updated. You need to use this position to transform your client.

PathPosition has get-fields:

  • Vector2 Position - position in 2d space
  • NormalizedVector2 Normal - forward direction
  • float Length - length from the beginning of the path

2. Communication with the path

For convenient interaction with the path, use PathGrip. Create an instance of this object and put it in a variable of type IPathGrip.

PathGrip(IPathClient client, IPath path) - Give him yourself and the path on which you want to move.

  • To attach your client to the path, use method Attach(Vector2 position)
  • Once a client has been attached to a path, it can be moved. To move the client forward by 1 pixel, pass 1f to the following Move(float movement) method

com.retrover.path2d's People

Contributors

yoopita avatar

Stargazers

lncp'ov avatar PanDurko avatar Aleksey Afanasyev avatar Anton avatar

Watchers

 avatar

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.