Liberi
An exergame built for kids with CP!
ConstantSpeed.cs
1 using UnityEngine;
2 
6 [AddComponentMenu("Liberi/Constant Speed")]
7 [RequireComponent(typeof(Rigidbody))]
8 [Script(ScriptRole.Owner)]
9 public class ConstantSpeed: MonoBehaviour
10 {
16  public float Speed;
17 
18  void OnSpawn (UJeli details)
19  {
20  if (details.HasChild("Velocity"))
21  Speed = details["Velocity"].Vector3Value.magnitude;
22  }
23 
24  void FixedUpdate ()
25  {
26  if (rigidbody.isKinematic)
27  return;
28 
29  rigidbody.velocity = rigidbody.velocity.normalized * Speed;
30  }
31 }
Makes this object maintain a constant speed.
Definition: ConstantSpeed.cs:9
float Speed
The speed to maintain.
Unity version of Jeli markup class.
Definition: UJeli.cs:10