Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Moving object down or up the spline using gravity
#4
Hi
I modified the class to implement a simple slope induced speed:

Code:
public class E10_MotorController : SplineController
    {
        [Section("Motor")]
        public float MaxSpeed = 30;
        public float SlopeFactor = 10;

        protected override void Update()
        {
            float axis = Input.GetAxis("Vertical");
            float slopeInducedSpeed = Mathf.Abs(GetTangent(RelativePosition).y) * SlopeFactor;
            Speed = Mathf.Abs(axis) * MaxSpeed + slopeInducedSpeed;
            MovementDirection = MovementDirectionMethods.FromInt((int)Mathf.Sign(axis));
            base.Update();
        }
    }

I hope this helped
Have a nice day
Available for freelance work, feel free to reach out: toolbuddy.net
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Reply


Messages In This Thread
RE: Moving object down or up the spline using gravity - by _Aka_ - 07-25-2023, 10:33 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Best way to duplicate a spline with an offset Kapistijn 8 1,297 04-12-2026, 03:18 PM
Last Post: _Aka_
Smile Constant speed along a spline? tfishell 1 645 11-13-2025, 11:32 AM
Last Post: _Aka_
  Create Game Object Renaming Options rickgplus 1 925 09-23-2025, 09:33 AM
Last Post: _Aka_
  SplineController Ignores Follow-Up and Chooses Wrong Spline Josenildo 7 4,432 07-29-2025, 09:15 PM
Last Post: _Aka_

Forum Jump: