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
Question Check Spline collisions (Pathfinding) Hukha 4 92 03-24-2020, 02:00 PM
Last Post: _Aka_
  Add Template problem in the Generator with Input Spline Shape prefab ATHellboy 1 119 03-13-2020, 11:27 PM
Last Post: _Aka_
  Spline object on a spline path ATHellboy 22 1,492 03-01-2020, 05:03 PM
Last Post: _Aka_
  Convert position of a point on a spline to another spline which is connected ATHellboy 5 412 02-17-2020, 12:17 PM
Last Post: _Aka_

Forum Jump: