mirror of
https://github.com/stride3d/stride.git
synced 2026-10-12 02:23:23 +00:00
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.
33 lines
1.1 KiB
C#
33 lines
1.1 KiB
C#
// 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.Linq;
|
|
using System.Threading.Tasks;
|
|
using Stride.Core.Mathematics;
|
|
using Stride.Engine;
|
|
|
|
namespace AnimatedModel
|
|
{
|
|
/// <summary>
|
|
/// Rotate the entity when user slide its finger on the screen.
|
|
/// </summary>
|
|
public class RotateEntity : AsyncScript
|
|
{
|
|
public override async Task Execute()
|
|
{
|
|
var rotationSpeed = 0f;
|
|
|
|
while (Game.IsRunning)
|
|
{
|
|
await Script.NextFrame();
|
|
|
|
if (Input.PointerEvents.Any())
|
|
rotationSpeed = 200f * Input.PointerEvents.Sum(x => x.DeltaPosition.X);
|
|
|
|
rotationSpeed *= 0.93f;
|
|
var elapsedTime = (float) Game.UpdateTime.WarpElapsed.TotalSeconds;
|
|
Entity.Transform.Rotation *= Quaternion.RotationY(rotationSpeed * elapsedTime);
|
|
}
|
|
}
|
|
}
|
|
}
|