Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SDK question(s)
#3
This should work with the SDK to duplicate the Pegasus motion.

When attaching the Pegasus model (or other vehicle) to VZPlayer, position so that the seat is at the origin of the VZPlayer. The NeckHeight parameter below presumes your eyes are 0.9 above that origin, so will remain vertical above the seat as the vehicle pitches up and down hills or when flying.

Another thing I left in the code is how the Pegasus dives, when you lean forward and not holding down A button (which in our SDK is Controller.RightButton). Diving is just a matter of letting you fall faster, as opposed to pushing down more.

Note to translate from Controller.InputSpeed to rpm, at the default difficulty of 5, divide by 6.462. That's the distance our initial prototype bike with 27" wheels traveled in one pedal revolution with a gear ratio of 3.

Code:
using UnityEngine;

public class VZSimplePegasus : VZPlayer
{
   /* VZPlayer settings

      NearClipPlane: 0.1
      FarClipPlane: 3000
      DraftSpeed: 0
      DraftFactor: 0
      SpeedFudge: 1
      DownhillFactor: 0.5
      UphillFactor: 1.414
      MaxVertSpeed: 4
      MaxTurn: 0.6 // for Gold Pegasus this becomes 0.7
      MaxSpeed: 12
      LeanFudge: 2.5 // for Gold Pegasus this becomes 3
      LeanIn: 0.5
      LandingHardness: 1.5 // for Gold Pegasus this becomes 2
      LandingRadius: 0.25
      NeckHeight: 0.9 // for pivot point at seat
      AllowRotate: 1
      AllowPitch: 1
      AllowRoll: 0
      AllowDrift: 1 // so she drifts rather than brakes in air when not pedaling
      RotateAtStop: 0
      SlowRotateLimit: 0
      AllowReverse: 0
      ForceReverse: 0
      ResistanceAdjust: 0
   */

   public float LiftSpeed = 7.0f;
   public float MaxHeight = 130.0f; // for Gold Pegasus this becomes 195
  
   protected override void FixedUpdate()
   {
      base.FixedUpdate();

      // Starts lifting at LiftSpeed
      Vector3 force = Vector3.zero;

      if (Controller.RightButton.Down)
         force.y = 9.81f * Controller.InputSpeed / LiftSpeed;

      // Lean forward to dive when coasting
      float bend = Controller.RightButton.Down ? 0 : Mathf.Clamp01(Controller.HeadBend / 0.2f);
      MaxVertSpeed = Mathf.Lerp(4, 7, bend);

      // Lift peters out at MaxHeight
      if (!Colliding() && Altitude() > 0)
         force.y -= 9.81f * Altitude() / MaxHeight;

      // Apply lift force
      GetRigidbody().AddForce(force);
   }
}
Reply


Messages In This Thread
SDK question(s) - by Stain2319 - 02-29-2020, 12:28 AM
RE: SDK question(s) - by emalafeew - 02-29-2020, 12:33 PM
RE: SDK question(s) - by emalafeew - 02-29-2020, 01:56 PM
RE: SDK question(s) - by emalafeew - 02-29-2020, 02:11 PM
RE: SDK question(s) - by Stain2319 - 02-29-2020, 03:49 PM
RE: SDK question(s) - by emalafeew - 02-29-2020, 03:57 PM
RE: SDK question(s) - by Stain2319 - 02-29-2020, 04:17 PM
RE: SDK question(s) - by Stain2319 - 02-29-2020, 11:39 PM
RE: SDK question(s) - by emalafeew - 03-01-2020, 08:38 AM
RE: SDK question(s) - by Stain2319 - 03-03-2020, 04:14 PM
RE: SDK question(s) - by Stain2319 - 03-03-2020, 07:00 PM
RE: SDK question(s) - by Stain2319 - 03-03-2020, 11:09 PM
RE: SDK question(s) - by Stain2319 - 03-05-2020, 03:10 PM
RE: SDK question(s) - by Stain2319 - 03-04-2020, 03:00 AM
RE: SDK question(s) - by Stain2319 - 03-09-2020, 10:40 PM
RE: SDK question(s) - by emalafeew - 03-10-2020, 12:02 PM
RE: SDK question(s) - by Stain2319 - 03-10-2020, 12:46 PM
RE: SDK question(s) - by emalafeew - 03-10-2020, 02:32 PM
RE: SDK question(s) - by Stain2319 - 03-10-2020, 02:54 PM
RE: SDK question(s) - by emalafeew - 03-10-2020, 03:54 PM
RE: SDK question(s) - by Stain2319 - 03-10-2020, 04:59 PM
RE: SDK question(s) - by emalafeew - 03-10-2020, 07:53 PM
RE: SDK question(s) - by Stain2319 - 03-11-2020, 01:13 AM
RE: SDK question(s) - by Stain2319 - 03-11-2020, 10:20 PM
RE: SDK question(s) - by emalafeew - 03-12-2020, 04:32 PM
RE: SDK question(s) - by Stain2319 - 03-12-2020, 05:57 PM
RE: SDK question(s) - by Stain2319 - 03-12-2020, 07:34 PM
RE: SDK question(s) - by Stain2319 - 03-12-2020, 11:07 PM
RE: SDK question(s) - by Stain2319 - 03-13-2020, 03:02 PM
RE: SDK question(s) - by emalafeew - 03-13-2020, 03:25 PM
RE: SDK question(s) - by Stain2319 - 03-18-2020, 02:53 AM
RE: SDK question(s) - by emalafeew - 03-19-2020, 02:05 PM
RE: SDK question(s) - by Stain2319 - 03-19-2020, 03:17 PM
RE: SDK question(s) - by Stain2319 - 03-22-2020, 02:35 AM
RE: SDK question(s) - by Stain2319 - 03-22-2020, 03:22 PM
RE: SDK question(s) - by emalafeew - 03-22-2020, 03:45 PM
RE: SDK question(s) - by Stain2319 - 03-22-2020, 03:47 PM
RE: SDK question(s) - by Stain2319 - 03-26-2020, 12:16 PM
RE: SDK question(s) - by emalafeew - 03-26-2020, 01:52 PM
RE: SDK question(s) - by emalafeew - 03-26-2020, 02:18 PM
RE: SDK question(s) - by Stain2319 - 03-26-2020, 03:07 PM
RE: SDK question(s) - by Stain2319 - 03-31-2020, 06:46 PM
RE: SDK question(s) - by emalafeew - 03-31-2020, 07:08 PM
RE: SDK question(s) - by Stain2319 - 03-31-2020, 07:41 PM
RE: SDK question(s) - by Stain2319 - 03-31-2020, 08:56 PM
RE: SDK question(s) - by Shon_T - 03-31-2020, 09:20 PM
RE: SDK question(s) - by Stain2319 - 03-31-2020, 10:18 PM
RE: SDK question(s) - by emalafeew - 04-01-2020, 02:58 PM
RE: SDK question(s) - by Snowpelt - 04-02-2020, 12:12 AM
RE: SDK question(s) - by emalafeew - 04-02-2020, 10:30 AM
RE: SDK question(s) - by Shon_T - 04-02-2020, 06:45 PM
RE: SDK question(s) - by Stain2319 - 04-10-2020, 03:46 PM
RE: SDK question(s) - by emalafeew - 04-13-2020, 04:40 PM
RE: SDK question(s) - by Stain2319 - 04-10-2020, 06:09 PM
RE: SDK question(s) - by Stain2319 - 04-14-2020, 02:29 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)