Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Find if object is on spline path
#1
Hi,

First of all, thanks for this amazing asset. It's really making a difference on our project. Big Grin
And about that project, I'm working on a endless runner game and I spawn prefabs very frequently. Sometimes a prefab spawns on a spline path and I need to find that spline to orientate the object according to spline orientation.
It there a way to detect if a spawned prefab is on a path of a previouly spawned spline?

Thanks!
Reply
#2
You are welcome Smile Glad to hear that Curvy is useful to you.

You can use
bool objectNearlyOnSpline = (yourSpline.GetNearestPoint(objectPosition) - objectPosition).magnitude < someSmallDistance;
If performance is an issue, you can use yourSpline.Bounds to test if the object is too far, and use sqrtMagnitude instead of magnitude.

I wrote this post on Android, on top of my head, so the code might have some typos, but the idea is there.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Bug Changing spline connection in inspector causes splines to revert to defaults lacota 3 6 03-18-2024, 07:55 PM
Last Post: _Aka_
  GO can't fit end of the spline GameDeveloperek4123 3 13 03-04-2024, 11:06 AM
Last Post: _Aka_
  Keeping a fixed spline length jh092 3 16 02-21-2024, 06:25 AM
Last Post: Primrose44
  How could I get position in spline from "From" value in BuildRasterizedPath? Chanon 1 8 02-12-2024, 09:54 PM
Last Post: _Aka_

Forum Jump: