Update templates and sample code to better support pausing (#3355)

Samples and templates: gameplay follows the time factor, camera and UI don't

Timers, cooldowns, speeds and animation now use UpdateTime.WarpElapsed, so they
stop when Factor is 0, like physics and particles already did. Camera, input and
UI keep UpdateTime.Elapsed.

The animation scripts also read UpdateTime instead of DrawTime, which is the
clock the engine's own animation system uses.

Removes the unused BasicCameraController from ThirdPersonPlatformer.
This commit is contained in:
Jeremy Pritts
2026-09-20 18:12:17 +09:00
committed by GitHub
parent 3b0b7df580
commit 765c7fb89c
35 changed files with 47 additions and 240 deletions
@@ -124,7 +124,7 @@ namespace JumpyJet
if (!isRunning)
continue;
var elapsedTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var elapsedTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
// apply impulse on the touch/space
if (Input.IsKeyPressed(Keys.Space) || UserTappedScreen())
@@ -66,7 +66,7 @@ namespace JumpyJet
if (!isScrolling)
return;
var elapsedTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var elapsedTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
for (int i = 0; i < pipeSets.Count; i++)
{
@@ -78,7 +78,7 @@ namespace SpaceEscape.Background
if (!isScrolling)
return;
var elapsedTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var elapsedTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
// Check if needed to remove the first block
var firstBlock = levelBlocks[0];
@@ -24,7 +24,7 @@ namespace AnimatedModel
rotationSpeed = 200f * Input.PointerEvents.Sum(x => x.DeltaPosition.X);
rotationSpeed *= 0.93f;
var elapsedTime = (float) Game.UpdateTime.Elapsed.TotalSeconds;
var elapsedTime = (float) Game.UpdateTime.WarpElapsed.TotalSeconds;
Entity.Transform.Rotation *= Quaternion.RotationY(rotationSpeed * elapsedTime);
}
}
@@ -103,7 +103,7 @@ namespace SpriteStudioDemo
if (inputState == InputState.RunLeft || inputState == InputState.RunRight)
{
// Update Agent's position
var dt = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var dt = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
Entity.Transform.Position.X += ((inputState == InputState.RunRight) ? AgentMoveDistance : -AgentMoveDistance) * dt;
@@ -81,7 +81,7 @@ namespace TouchInputs
public override void Update()
{
var currentTime = Game.DrawTime.Total;
var currentTime = Game.UpdateTime.Total;
keyDown = "";
keyEvents = "";
@@ -248,7 +248,7 @@ namespace TouchInputs
{
var screenSize = spriteBatch.VirtualResolution.Value;
var position = tuple.Item1;
var duration = Game.DrawTime.Total - tuple.Item2;
var duration = Game.UpdateTime.Total - tuple.Item2;
var scale = (float)(0.2f * (1f - duration.TotalSeconds / displayPointerDuration.TotalSeconds));
var pointerScreenPosition = new Vector2(position.X * screenSize.X, position.Y * screenSize.Y);
@@ -115,7 +115,7 @@ namespace ParticlesSample
while (secondsCountdown > 0f)
{
await Script.NextFrame();
secondsCountdown -= (float)Game.UpdateTime.Elapsed.TotalSeconds;
secondsCountdown -= (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
}
// Remove
@@ -24,7 +24,7 @@ namespace ParticlesSample
rotationSpeed = 200f * Input.PointerEvents.Sum(x => x.DeltaPosition.X);
rotationSpeed *= 0.93f;
var elapsedTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var elapsedTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
Entity.Transform.Rotation *= Quaternion.RotationY(rotationSpeed * elapsedTime);
}
}
@@ -123,7 +123,7 @@ namespace FirstPersonShooter.Player
// Update current animation
var currentTicks = TimeSpan.FromTicks((long)(currentTime * currentClip.Duration.Ticks));
var updatedTicks = currentTicks.Ticks + (long)(Game.DrawTime.Elapsed.Ticks * TimeFactor);
var updatedTicks = currentTicks.Ticks + (long)(Game.UpdateTime.WarpElapsed.Ticks * TimeFactor);
var currentClipFinished = (updatedTicks >= currentClip.Duration.Ticks);
@@ -56,7 +56,7 @@ namespace FirstPersonShooter.Player
while (secondsCountdown > 0f)
{
await Script.NextFrame();
secondsCountdown -= (float) Game.UpdateTime.Elapsed.TotalSeconds;
secondsCountdown -= (float) Game.UpdateTime.WarpElapsed.TotalSeconds;
}
remainingBullets = 9;
@@ -77,7 +77,7 @@ namespace FirstPersonShooter.Player
bool didReload;
reloadEvent.TryReceive(out didReload);
cooldownRemaining = (cooldownRemaining > 0) ? (cooldownRemaining - (float)this.Game.UpdateTime.Elapsed.TotalSeconds) : 0f;
cooldownRemaining = (cooldownRemaining > 0) ? (cooldownRemaining - (float)this.Game.UpdateTime.WarpElapsed.TotalSeconds) : 0f;
if (cooldownRemaining > 0)
return; // Can't shoot yet
@@ -59,7 +59,7 @@ namespace FirstPersonShooter
while (secondsCountdown > 0f)
{
await Script.NextFrame();
secondsCountdown -= (float)Game.UpdateTime.Elapsed.TotalSeconds;
secondsCountdown -= (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
}
// Remove
@@ -19,7 +19,7 @@ public class CoinRotation : SyncScript
public override void Update()
{
animationTimer += (float) Game.UpdateTime.Elapsed.TotalSeconds;
animationTimer += (float) Game.UpdateTime.WarpElapsed.TotalSeconds;
if (animationTimer >= animationInterval)
{
@@ -93,7 +93,7 @@ public class PlayerController : SyncScript
private void HandleAnimation(bool isMoving)
{
animationTimer += (float) Game.UpdateTime.Elapsed.TotalSeconds;
animationTimer += (float) Game.UpdateTime.WarpElapsed.TotalSeconds;
if (CharacterComponent.IsGrounded && !isMoving)
{
@@ -1,188 +0,0 @@
// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
using System;
using Stride.Core;
using Stride.Core.Mathematics;
using Stride.Engine;
using Stride.Input;
namespace ThirdPersonPlatformer
{
/// <summary>
/// A script that allows to move and rotate an entity through keyboard, mouse and touch input to provide basic camera navigation.
/// </summary>
/// <remarks>
/// The entity can be moved using W, A, S, D, Q and E, arrow keys or dragging/scaling using multi-touch.
/// Rotation is achieved using the Numpad, the mouse while holding the right mouse button, or dragging using single-touch.
/// </remarks>
public class BasicCameraController : SyncScript
{
private const float MaximumPitch = MathUtil.PiOverTwo * 0.99f;
private Vector3 upVector;
private Vector3 translation;
private float yaw;
private float pitch;
public Vector3 KeyboardMovementSpeed { get; set; } = new Vector3(5.0f);
public Vector3 TouchMovementSpeed { get; set; } = new Vector3(40, 40, 20);
public float SpeedFactor { get; set; } = 5.0f;
public Vector2 KeyboardRotationSpeed { get; set; } = new Vector2(3.0f);
public Vector2 MouseRotationSpeed { get; set; } = new Vector2(90.0f, 60.0f);
public Vector2 TouchRotationSpeed { get; set; } = new Vector2(60.0f, 40.0f);
public override void Start()
{
base.Start();
// Default up-direction
upVector = Vector3.UnitY;
// Configure touch input
if (!Platform.IsWindowsDesktop)
{
Input.Gestures.Add(new GestureConfigDrag());
Input.Gestures.Add(new GestureConfigComposite());
}
}
public override void Update()
{
ProcessInput();
UpdateTransform();
}
private void ProcessInput()
{
translation = Vector3.Zero;
yaw = 0;
pitch = 0;
// Move with keyboard
if (Input.IsKeyDown(Keys.W) || Input.IsKeyDown(Keys.Up))
{
translation.Z = -KeyboardMovementSpeed.Z;
}
else if (Input.IsKeyDown(Keys.S) || Input.IsKeyDown(Keys.Down))
{
translation.Z = KeyboardMovementSpeed.Z;
}
if (Input.IsKeyDown(Keys.A) || Input.IsKeyDown(Keys.Left))
{
translation.X = -KeyboardMovementSpeed.X;
}
else if (Input.IsKeyDown(Keys.D) || Input.IsKeyDown(Keys.Right))
{
translation.X = KeyboardMovementSpeed.X;
}
if (Input.IsKeyDown(Keys.Q))
{
translation.Y = -KeyboardMovementSpeed.Y;
}
else if (Input.IsKeyDown(Keys.E))
{
translation.Y = KeyboardMovementSpeed.Y;
}
// Alternative translation speed
if (Input.IsKeyDown(Keys.LeftShift) || Input.IsKeyDown(Keys.RightShift))
{
translation *= SpeedFactor;
}
// Rotate with keyboard
if (Input.IsKeyDown(Keys.NumPad2))
{
pitch = KeyboardRotationSpeed.X;
}
else if (Input.IsKeyDown(Keys.NumPad8))
{
pitch = -KeyboardRotationSpeed.X;
}
if (Input.IsKeyDown(Keys.NumPad4))
{
yaw = KeyboardRotationSpeed.Y;
}
else if (Input.IsKeyDown(Keys.NumPad6))
{
yaw = -KeyboardRotationSpeed.Y;
}
// Rotate with mouse
if (Input.IsMouseButtonDown(MouseButton.Right))
{
Input.LockMousePosition();
Game.IsMouseVisible = false;
yaw = -Input.MouseDelta.X * MouseRotationSpeed.X;
pitch = -Input.MouseDelta.Y * MouseRotationSpeed.Y;
}
else
{
Input.UnlockMousePosition();
Game.IsMouseVisible = true;
}
// Handle gestures
foreach (var gestureEvent in Input.GestureEvents)
{
switch (gestureEvent.Type)
{
// Rotate by dragging
case GestureType.Drag:
var drag = (GestureEventDrag)gestureEvent;
var dragDistance = drag.DeltaTranslation;
yaw = -dragDistance.X * TouchRotationSpeed.X;
pitch = -dragDistance.Y * TouchRotationSpeed.Y;
break;
// Move along z-axis by scaling and in xy-plane by multi-touch dragging
case GestureType.Composite:
var composite = (GestureEventComposite)gestureEvent;
translation.X = -composite.DeltaTranslation.X * TouchMovementSpeed.X;
translation.Y = -composite.DeltaTranslation.Y * TouchMovementSpeed.Y;
translation.Z = -(float)Math.Log(composite.DeltaScale + 1) * TouchMovementSpeed.Z;
break;
}
}
}
private void UpdateTransform()
{
var elapsedTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;
translation *= elapsedTime;
yaw *= elapsedTime;
pitch *= elapsedTime;
// Get the local coordinate system
var rotation = Matrix.RotationQuaternion(Entity.Transform.Rotation);
// Enforce the global up-vector by adjusting the local x-axis
var right = Vector3.Cross(rotation.Forward, upVector);
var up = Vector3.Cross(right, rotation.Forward);
// Stabilize
right.Normalize();
up.Normalize();
// Adjust pitch. Prevent it from exceeding up and down facing. Stabilize edge cases.
var currentPitch = MathUtil.PiOverTwo - (float)Math.Acos(Vector3.Dot(rotation.Forward, upVector));
pitch = MathUtil.Clamp(currentPitch + pitch, -MaximumPitch, MaximumPitch) - currentPitch;
// Move in local coordinates
Entity.Transform.Position += Vector3.TransformCoordinate(translation, rotation);
// Yaw around global up-vector, pitch and roll in local space
Entity.Transform.Rotation *= Quaternion.RotationAxis(right, pitch) * Quaternion.RotationAxis(upVector, yaw);
}
}
}
@@ -139,8 +139,7 @@ namespace ThirdPersonPlatformer.Player
animationClipWalkLerp2 = AnimationRun;
}
// Use DrawTime rather than UpdateTime
var time = Game.DrawTime;
var time = Game.UpdateTime;
// This update function will account for animation with different durations, keeping a current time relative to the blended maximum duration
long blendedMaxDuration = 0;
blendedMaxDuration =
@@ -150,7 +149,7 @@ namespace ThirdPersonPlatformer.Player
currentTicks = blendedMaxDuration == 0
? TimeSpan.Zero
: TimeSpan.FromTicks((currentTicks.Ticks + (long)(time.Elapsed.Ticks * TimeFactor)) %
: TimeSpan.FromTicks((currentTicks.Ticks + (long)(time.WarpElapsed.Ticks * TimeFactor)) %
blendedMaxDuration);
currentTime = ((double)currentTicks.Ticks / (double)blendedMaxDuration);
@@ -160,7 +159,7 @@ namespace ThirdPersonPlatformer.Player
{
var speedFactor = 1;
var currentTicks = TimeSpan.FromTicks((long)(currentTime * AnimationJumpStart.Duration.Ticks));
var updatedTicks = currentTicks.Ticks + (long)(Game.DrawTime.Elapsed.Ticks * TimeFactor * speedFactor);
var updatedTicks = currentTicks.Ticks + (long)(Game.UpdateTime.WarpElapsed.Ticks * TimeFactor * speedFactor);
if (updatedTicks < AnimationJumpStart.Duration.Ticks)
{
@@ -177,10 +176,9 @@ namespace ThirdPersonPlatformer.Player
private void UpdateAirborne()
{
// Use DrawTime rather than UpdateTime
var time = Game.DrawTime;
var time = Game.UpdateTime;
var currentTicks = TimeSpan.FromTicks((long)(currentTime * AnimationJumpMid.Duration.Ticks));
currentTicks = TimeSpan.FromTicks((currentTicks.Ticks + (long)(time.Elapsed.Ticks * TimeFactor)) %
currentTicks = TimeSpan.FromTicks((currentTicks.Ticks + (long)(time.WarpElapsed.Ticks * TimeFactor)) %
AnimationJumpMid.Duration.Ticks);
currentTime = ((double)currentTicks.Ticks / (double)AnimationJumpMid.Duration.Ticks);
}
@@ -189,7 +187,7 @@ namespace ThirdPersonPlatformer.Player
{
var speedFactor = 1;
var currentTicks = TimeSpan.FromTicks((long)(currentTime * AnimationJumpEnd.Duration.Ticks));
var updatedTicks = currentTicks.Ticks + (long) (Game.DrawTime.Elapsed.Ticks * TimeFactor * speedFactor);
var updatedTicks = currentTicks.Ticks + (long) (Game.UpdateTime.WarpElapsed.Ticks * TimeFactor * speedFactor);
if (updatedTicks < AnimationJumpEnd.Duration.Ticks)
{
@@ -61,7 +61,6 @@ namespace ThirdPersonPlatformer.Player
/// </summary>
public override void Update()
{
// var dt = Game.UpdateTime.Elapsed.Milliseconds * 0.001;
Move(MaxRunSpeed);
Jump();
@@ -77,7 +77,7 @@ namespace TopDownRPG.Core
while (secondsCountdown > 0f)
{
await script.Script.NextFrame();
secondsCountdown -= (float)script.Game.UpdateTime.Elapsed.TotalSeconds;
secondsCountdown -= (float)script.Game.UpdateTime.WarpElapsed.TotalSeconds;
}
// Remove
@@ -43,7 +43,7 @@ namespace TopDownRPG.Gameplay
public void UpdateAnimation()
{
var dt = (float) Game.UpdateTime.Elapsed.TotalSeconds;
var dt = (float) Game.UpdateTime.WarpElapsed.TotalSeconds;
Entity.Transform.Rotation *= Quaternion.RotationMatrix(Matrix.RotationY(spinSpeed * (float)(dt * Math.PI)));
if (!activated)
@@ -46,7 +46,7 @@ namespace TopDownRPG.Gameplay
if (!activated)
return;
var dt = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var dt = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
animationTime += dt * 8;
var coinHeight = Math.Max(0, Math.Sin(animationTime));
@@ -44,7 +44,7 @@ namespace TopDownRPG.Gameplay
public void UpdateAnimation()
{
var dt = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var dt = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
if (!activated)
return;
@@ -121,8 +121,7 @@ namespace TopDownRPG.Player
animationClipWalkLerp2 = AnimationRun;
}
// Use DrawTime rather than UpdateTime
var time = Game.DrawTime;
var time = Game.UpdateTime;
// This update function will account for animation with different durations, keeping a current time relative to the blended maximum duration
long blendedMaxDuration = 0;
blendedMaxDuration =
@@ -132,7 +131,7 @@ namespace TopDownRPG.Player
currentTicks = blendedMaxDuration == 0
? TimeSpan.Zero
: TimeSpan.FromTicks((currentTicks.Ticks + (long)(time.Elapsed.Ticks * TimeFactor)) %
: TimeSpan.FromTicks((currentTicks.Ticks + (long)(time.WarpElapsed.Ticks * TimeFactor)) %
blendedMaxDuration);
currentTime = ((double)currentTicks.Ticks / (double)blendedMaxDuration);
@@ -142,7 +141,7 @@ namespace TopDownRPG.Player
{
var speedFactor = 1;
var currentTicks = TimeSpan.FromTicks((long)(currentTime * AnimationPunch.Duration.Ticks));
var updatedTicks = currentTicks.Ticks + (long)(Game.DrawTime.Elapsed.Ticks * TimeFactor * speedFactor);
var updatedTicks = currentTicks.Ticks + (long)(Game.UpdateTime.WarpElapsed.Ticks * TimeFactor * speedFactor);
if (updatedTicks < AnimationPunch.Duration.Ticks)
{
@@ -123,7 +123,7 @@ namespace TopDownRPG.Player
private void Attack()
{
var dt = (float) Game.UpdateTime.Elapsed.TotalSeconds;
var dt = (float) Game.UpdateTime.WarpElapsed.TotalSeconds;
attackCooldown = (attackCooldown > 0) ? attackCooldown - dt : 0f;
PunchCollision.Enabled = (attackCooldown > 0);
@@ -30,7 +30,7 @@ namespace CSharpBeginner.Code
public override void Update()
{
/// We can access Delta time through the static 'Game' object.
var deltaTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var deltaTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
// We update the total time
totalTime += deltaTime;
@@ -27,7 +27,7 @@ namespace CSharpBeginner.Code
DebugText.Print("Hold the 1 key down to rotate the blue teapot", new Int2(340, 500));
if (Input.IsKeyDown(Keys.D1))
{
var deltaTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var deltaTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
BlueTeapot.Transform.Rotation *= Quaternion.RotationY(0.3f * deltaTime);
}
@@ -30,7 +30,7 @@ namespace CSharpBeginner.Code
public override void Update()
{
// Keep track of elapsed time
var deltaTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var deltaTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
elapsedTime += deltaTime;
// In order to make use of the lerp method, we need to calculate the 'interpolation value': a value going from 0 to 1.
@@ -30,7 +30,7 @@ namespace CSharpBeginner.Code
DebugText.Print("Hold the left mouse button down to rotate the blue teapot", new Int2(400, 600));
if (Input.IsMouseButtonDown(MouseButton.Left))
{
var deltaTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var deltaTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
BlueTeapot.Transform.Rotation *= Quaternion.RotationY(0.4f * deltaTime);
}
@@ -49,7 +49,7 @@ namespace CSharpBeginner.Code
public override void Update()
{
// We use a simple timer
timer += (float)Game.UpdateTime.Elapsed.TotalSeconds;
timer += (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
if (timer > currentTimer)
{
// If the entities exist, we remove them from the scene
@@ -49,7 +49,7 @@ namespace CSharpBeginner.Code
// Note: Gamepad sticks can be a negative value. For this example we only check if the value is higher than 0
if (forward > 0)
{
var deltaTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var deltaTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
BlueTeapot.Transform.Rotation *= Quaternion.RotationY(0.6f * forward * deltaTime);
}
@@ -48,7 +48,7 @@ namespace CSharpIntermediate.Code
return;
}
var deltaTime = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var deltaTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
var curPosition = RegularCharacter.Transform.WorldMatrix.TranslationVector;
var nextWaypointPosition = waypoints[waypointIndex];
var distanceToWaypoint = Vector3.Distance(curPosition, nextWaypointPosition);
@@ -55,7 +55,7 @@ namespace CSharpIntermediate.Code
movement.X -= 1;
}
var delta = (float)Game.UpdateTime.Elapsed.TotalSeconds;
var delta = (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
Entity.Transform.Position += movement * delta * MoveSpeed;
}
}
@@ -211,7 +211,7 @@ namespace UIParticles
while (secondsCountdown > 0f)
{
await Script.NextFrame();
secondsCountdown -= (float)Game.UpdateTime.Elapsed.TotalSeconds;
secondsCountdown -= (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
}
// Remove
@@ -283,7 +283,7 @@ namespace UIParticles
private void DrawFuse()
{
fusePercentage = Math.Min(1f, fusePercentage - (float)Game.UpdateTime.Elapsed.TotalSeconds * 0.04f);
fusePercentage = Math.Min(1f, fusePercentage - (float)Game.UpdateTime.WarpElapsed.TotalSeconds * 0.04f);
var gaugeCurrentRegion = lifeBarGaugeImage.Region;
gaugeCurrentRegion.Width = Math.Max(1, fusePercentage * gaugeBarRegion.Width);
@@ -323,7 +323,7 @@ namespace UIParticles
private void NewGameState()
{
fusePercentage = Math.Min(1f, fusePercentage - (float)Game.UpdateTime.Elapsed.TotalSeconds * 0.03f);
fusePercentage = Math.Min(1f, fusePercentage - (float)Game.UpdateTime.WarpElapsed.TotalSeconds * 0.03f);
DrawFuse();
if (desiredState == GameState.EndGame || fusePercentage <= 0f)
@@ -58,8 +58,7 @@ public class ##Scriptname## : SyncScript, IBlendTreeBuilder
public override void Update()
{
// Use DrawTime rather than UpdateTime
var time = Game.DrawTime;
var time = Game.UpdateTime;
// This update function will account for animation with different durations, keeping a current time relative to the blended maximum duration
long blendedMaxDuration = 0;
@@ -67,7 +66,7 @@ public class ##Scriptname## : SyncScript, IBlendTreeBuilder
var currentTicks = TimeSpan.FromTicks((long)(currentTime * blendedMaxDuration));
currentTicks = blendedMaxDuration == 0 ? TimeSpan.Zero : TimeSpan.FromTicks((currentTicks.Ticks + (long)(time.Elapsed.Ticks * TimeFactor)) % blendedMaxDuration);
currentTicks = blendedMaxDuration == 0 ? TimeSpan.Zero : TimeSpan.FromTicks((currentTicks.Ticks + (long)(time.WarpElapsed.Ticks * TimeFactor)) % blendedMaxDuration);
currentTime = (currentTicks.Ticks/(double) blendedMaxDuration);
}
@@ -44,7 +44,7 @@ public class ##Scriptname## : SyncScript
// Condition 2 - the trigger can be a time interval
if (TimeInterval > 0)
{
timeIntervalCountdown -= (float)Game.UpdateTime.Elapsed.TotalSeconds;
timeIntervalCountdown -= (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
if (timeIntervalCountdown <= 0f)
{
timeIntervalCountdown = TimeInterval;
@@ -97,7 +97,7 @@ public class ##Scriptname## : SyncScript
var rotationDelta = Input.MouseDelta;
// Compute translation speed according to framerate and modifiers
var translationSpeed = Speed * (float)Game.UpdateTime.Elapsed.TotalSeconds;
var translationSpeed = Speed * (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
// Take shortest path
var deltaPitch = desiredPitch - pitch;
@@ -109,7 +109,7 @@ public class ##Scriptname## : SyncScript
desiredYaw = yaw + deltaYaw;
// Perform orientation transition
var rotationAdaptation = (float)Game.UpdateTime.Elapsed.TotalSeconds * RotationAdaptationSpeed;
var rotationAdaptation = (float)Game.UpdateTime.WarpElapsed.TotalSeconds * RotationAdaptationSpeed;
yaw = Math.Abs(deltaYaw) < rotationAdaptation ? desiredYaw : yaw + rotationAdaptation * Math.Sign(deltaYaw);
pitch = Math.Abs(deltaPitch) < rotationAdaptation ? desiredPitch : pitch + rotationAdaptation * Math.Sign(deltaPitch);
@@ -69,7 +69,7 @@ public class ##Scriptname## : AsyncScript
if (TimeInterval > 0)
{
timeIntervalCountdown -= (float)Game.UpdateTime.Elapsed.TotalSeconds;
timeIntervalCountdown -= (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
if (timeIntervalCountdown <= 0f)
{
timeIntervalCountdown = TimeInterval;
@@ -115,7 +115,7 @@ public class ##Scriptname## : AsyncScript
while (secondsCountdown > 0f)
{
await Script.NextFrame();
secondsCountdown -= (float)Game.UpdateTime.Elapsed.TotalSeconds;
secondsCountdown -= (float)Game.UpdateTime.WarpElapsed.TotalSeconds;
}
// Remove