A bunch of little suggestions not worth their own thread:
-Rigidbody Spline Follow. Currently only transforms are supported. Of course the rigidbody would still remain able to receive external forces even while following the spline.
-Spline Projection. The ability for any transform to be able to determine the closest point to a target spline.
-Baking deformed mesh. Sometimes you deform a heavy mesh and it would be useful to bake them so you can apply techniques like GPU Instancing more efficiently.
Misc. Suggestions
- Edited
And I promise you won't have to hear about me again after this thread
(Baking deformed mesh is not expected to work at runtime of course, only at editor time.)
- Edited
Thanks for the feedback.
Rigidbody Spline Follow
Need to look into this a bit and see how much is needed for it to work. Can't say if I add it or not.
Spline Projection
You can already do this.
Example:
using UnityEngine;
using CurveArchitect.Objects;
using CurveArchitect.Utilities;
public class SplineProjection : MonoBehaviour
{
public ArchitectCurve ac;
public Transform transform;
private void Update()
{
Vector3 closestPoint = BezierCurve.ClosestPoint(ac, transform.position, 6, out _);
Debug.Log(closestPoint);
}
}
Baking deformed mesh
Do you want to bake/export the mesh to the project folder? Seems like something I should have done. I will likely add this.
Currently all deformed meshes is stored in the scene file or only stored in build/generated during editor mode. I have also remade the system that handles all deformed meshes. In the next version you can set how the all meshes is handled per Architect Curve.
- Generate
- Store in build, generate during editor mode.
- Save in scene file.
Let me know if I misunderstood something.
And I promise you won't have to hear about me again after this thread
I enjoy hearing users' thoughts, so if you have any more suggestions, I'd be happy to hear them.
Do you want to bake/export the mesh to the project folder? Seems like something I should have done. I will likely add this.
That's exactly it.
Regarding Rigidbody on Splines: yeah, I myself believe it is more of a "how would you implement it yourself" because there is no right/proper/correct way.
There's this one for example whose creator calls it "inelegant" even though it is perfectly functional:
Basically every frame you re-align the rigidbody of the joint to the closest position on the spline. Literally just transform.position = Spline.GetSplinePositionClosestToObjectPosition(transform.position); You don't want to use rigidbody.position because PhysX will calculate velocities it'self. You should calculate them yourself. I simply apply the rotation of the tangent with something like Quaternion.LookRotation(SplinePosition.forwardVector, SplinePosition.upVector); and to handle velocity, you can just use a Dot product like so rigidbody.velocity = Vector3.Dot(rigidbody.velocity, forwardVector);
From https://www.reddit.com/r/Unity3D/comments/ii2gho/spline_based_rigidbody_train_physics/
And thanks for your time!
- Edited
Rocky101 Ohh that's what you meant with "Rigidbody on Splines". I would say that you can do it quiet easily. All ArchitectCurveObjects (transforms on the curve) has a Vector3 called localCurvePosition. You can use localCurvePosition exactly has you move an regular transform with transform.position (aco.localCurvePosition.z += Time.DeltaTime * speed).
I would do something like this:
- Move objectA with localCurvePosition.z += Time.DeltaTime * acceleration * speed.
- Detect collision by checking bounds or localCurvePositions.
- Add an acceleration to the objectB on collision. Remove some acceleration on the other objectA.
You could even add physics from Unitys rigidbody on very hard collisions. Just detach the ArchitectCurveObject, and during the same frame apply force to the RigidBody.
Seems like a fun thing to do. Will likely add some examples for this in a later release.