Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Wheel Collider to propel along Spline
#1
Hi guys, I'm new to this tool and am giving it a try for a physics-based game I'm just starting to figure out how to best implement.

My goal is to have a wheeled vehicle follow a spline but for it to be propelled by real physics, such as with a wheel collider as we have currently in Unity. I've tried searching the forum but couldn't find anything specific to using the Wheel Collider instead of RigidBody.AddForce. I'm also looking to have it be connected to other wheeled objects that will be pulled along by that initial player-controlled unit, kind of like a train, the goal here having accurate wheel physics.

Can Curvy be used for this, and if so any advice on how to try approaching it? I can otherwise consider trying it with RigidBody.AddForce, that's just something I have no experience in at all yet but I'm sure can be done.

Thanks!
Reply
#2
Hi,
I am not familiar with wheel collider, but from reading the documentation I see that it has a steerAngle property. This is what I think you should modify. At each frame, compute the angle between the car's front, and the spline's tangent, and apply that angle to the wheel collider.
Useful API methods:
- CurvySpline.GetTangent
- CurvySpline.GetNearestPointTF
See api.curvyeditor.com for more information
Let me know if you need something else
Have a nice day
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#3
(08-23-2019, 10:09 PM)_Aka_ Wrote: Hi,
I am not familiar with wheel collider, but from reading the documentation I see that it has a steerAngle property. This is what I think you should modify. At each frame, compute the angle between the car's front, and the spline's tangent, and apply that angle to the wheel collider.
Useful API methods:
- CurvySpline.GetTangent
- CurvySpline.GetNearestPointTF
See api.curvyeditor.com for more information
Let me know if you need something else
Have a nice day

Thanks for the response, getting back to this so late because I keep jumping on and off this project for other things, looking at it again just now.

I was looking at the RigidBody example with the controllable ball on a ramp and I was wondering whether you could make any suggestions on how to clamp a RigidBody directly to a spline, if that's the right word for it, while still allowing RigidBody physics to still apply? I've been trying a few things such as based off the RigidBody example but without much luck so far. I'm having some trouble wrapping my head around all the API options as I'm still new to all the maths and the terms that goes into this kind of solution.

Also, just wondering, are there any plans to adapt CurvySpline to ECS? I know it's still pretty early but just wondering if that's been looked into at all yet since it is the (kind of distant) future of Unity.

Thanks again.
Reply
#4
Hi,

I will start with your last question: no ECS plan for now. I am right now not convinced about the benefits of converting a big codebase such as Curvy to ECS, compared to its cost (time wise). But I might change my mind in the future.

About clamping an object to a spline, what you can do is to put a Spline Controller on an object A with a mesh, and set its speed to 0. Then have another object B with the rigidbody and no mesh. At each frame, set B to A's position, apply the forces on B, let the physics update, measure the distance B moved with, then update A's Spline Controller's position accordingly. Did you get the idea?
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#5
Hi, I know this is an old post but I found a solution that worked perfectly for me (just requires modifying with curvy spline API) and hopefully will help other forum users.

https://answers.unity.com/questions/205406/constraining-rigidbody-to-spline.html
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Curvy Line Renderer for UI Spline? gekido 1 1 Yesterday, 10:12 PM
Last Post: _Aka_
  Get position of all control points for a spline gekido 1 2 Yesterday, 10:08 PM
Last Post: _Aka_
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_

Forum Jump: