Path system

Started by
7 comments, last by Nypyren 7 years, 1 month ago

I'm creating a path system because the Unity engine doesn't provide any.

Let's say I have a script called CircularPath, this path is a circle shape path which has radius, center point and angle variables. The angle variable specifies where the object is on the circle circumference. Now, if I create the path object which holds the CircularPath script and I create a game object which I want it move in the path, I want the game object to be snapped to it's rightful position already in the editor mode and not only in play mode then how do I do it?

I tried using the attribute ExecuteInEditMode but it doesn't good for my need.

I hope someone can help me with that,

Thank you in advance.

Advertisement

What type of "path" system? I understand "circular" and "angular", but by "path" do you mean navigation?

Have you looked at the navigation mesh system?

What type of "path" system? I understand "circular" and "angular", but by "path" do you mean navigation?

Have you looked at the navigation mesh system?

I am talking about 2d path, which I can attach to an object and then the object move on the path in a fixed speed. No physics needed.

GameMaker engine have it, it looks like this: https://docs.yoyogames.com/source/dadiospice/001_advanced%20use/004_paths.html

I'm trying to make the same thing but without editor.

So more like this spline controller? There are quite a few motion systems out there, including a bunch on the Unity store for free or low cost if you don't feel like re-inventing the wheel.

So more like this spline controller?

why it's called spline? looks like a regular path to me..

So more like this spline controller? There are quite a few motion systems out there, including a bunch on the Unity store for free or low cost if you don't feel like re-inventing the wheel.

I looked for it along time ago. There is an animation system call leantween which is free that have this path system in its non-free version.

I'm not going to pay money for this.

ExecuteInEditMode will behave slightly differently than running normally, but you should be able to at least get the object to move to its starting point in Awake.

I'm assuming you're going to set the object's transform relative to its parent? If you're trying to set its position relative to ITSELF at edit time, you're going to be in for a world of pain.

You might also need a custom inspector which can manipulate your component. https://unity3d.com/learn/tutorials/topics/interface-essentials/building-custom-inspector

If you absolutely need it, here is another thing you can use: http://answers.unity3d.com/questions/39313/how-do-i-get-a-callback-every-frame-in-edit-mode.html

I'm assuming you're going to set the object's transform relative to its parent? If you're trying to set its position relative to ITSELF at edit time, you're going to be in for a world of pain.

Can you explain yourself please?

I'm assuming you're going to set the object's transform relative to its parent? If you're trying to set its position relative to ITSELF at edit time, you're going to be in for a world of pain.

Can you explain yourself please?


A circular path needs a center point, or some other way of keeping the overall circle shape in a stable location. If you are defining the center point as the position of the transform of the same object that you want to travel in the circle, then moving that transform will move the center point. If you then repeat the process, you would see your game object fly off in a straight line, indefinitely, instead of travelling in a circle.

So, you need your center point to be defined some other way. The most "Unity-like" way to do that would be to treat the parent gameobject's transform's position as the center of the circle.

This topic is closed to new replies.

Advertisement