SCRIPTING API / Physics / RigidBody
RigidBody
Script access to an entity's Rigid Body: body type, mass, damping, velocities, sleep and axis locks. Bodies move in fixed steps.
Kindclass
NamespaceKroys.EngineScripting
Members39
Source
Generated/NativeComponents.g.cs, NativeComponents.csEXAMPLE
In a script
Component access: every member takes the entity first, for example RigidBody.Has(Entity). The values are the ones the Inspector shows for this component.
Gameplay.cs
public sealed class JumpPad : EntityScript { public float LaunchSpeed = 12.0f; protected override void OnTriggerEnter(Entity other) { // Dynamic bodies get launched; static and kinematic ones are left alone. if (!RigidBody.Has(other) || RigidBody.GetBodyType(other) != BodyType.Dynamic) return; Vector3 velocity = RigidBody.GetLinearVelocity(other); velocity.Y = LaunchSpeed; RigidBody.SetLinearVelocity(other, velocity); RigidBody.SetAwake(other, true); } protected override void OnCollisionEnter(Collision collision) { // Contacts arrive after the fixed step in which the bodies touched. Debug.Log($"{collision.Other.Name} hit the pad at {collision.Point}"); } }
REFERENCE
Members
Methods
#public static bool Has(Entity e)Whether the entity has a Rigid Body component.
#public static BodyType GetBodyType(Entity e)Reads the Rigid Body component's Body Type value of the entity.
#public static void SetBodyType(Entity e, BodyType value)Sets the Rigid Body component's Body Type value on the entity.
#public static bool IsEnabled(Entity e)Reads the Rigid Body component's Enabled value of the entity.
#public static void SetEnabled(Entity e, bool value)Sets the Rigid Body component's Enabled value on the entity.
#public static bool UsesGravity(Entity e)Reads the Rigid Body component's Gravity value of the entity.
#public static void SetUseGravity(Entity e, bool value)Sets the Rigid Body component's Use Gravity value on the entity.
#public static bool IsAwake(Entity e)Reads the Rigid Body component's Awake value of the entity.
#public static void SetAwake(Entity e, bool value)Sets the Rigid Body component's Awake value on the entity.
#public static float GetMass(Entity e)Reads the Rigid Body component's Mass value of the entity.
#public static void SetMass(Entity e, float value)Sets the Rigid Body component's Mass value on the entity.
#public static float GetLinearDamping(Entity e)Reads the Rigid Body component's Linear Damping value of the entity.
#public static void SetLinearDamping(Entity e, float value)Sets the Rigid Body component's Linear Damping value on the entity.
#public static float GetAngularDamping(Entity e)Reads the Rigid Body component's Angular Damping value of the entity.
#public static void SetAngularDamping(Entity e, float value)Sets the Rigid Body component's Angular Damping value on the entity.
#public static float GetGravityScale(Entity e)Reads the Rigid Body component's Gravity Scale value of the entity.
#public static void SetGravityScale(Entity e, float value)Sets the Rigid Body component's Gravity Scale value on the entity.
#public static Vector3 GetLinearVelocity(Entity e)Reads the Rigid Body component's Linear Velocity value of the entity.
#public static void SetLinearVelocity(Entity e, Vector3 value)Sets the Rigid Body component's Linear Velocity value on the entity.
#public static Vector3 GetAngularVelocity(Entity e)Reads the Rigid Body component's Angular Velocity value of the entity.
#public static void SetAngularVelocity(Entity e, Vector3 value)Sets the Rigid Body component's Angular Velocity value on the entity.
#public static Vector3 GetInertiaTensor(Entity e)Reads the Rigid Body component's Inertia Tensor value of the entity.
#public static void SetInertiaTensor(Entity e, Vector3 value)Sets the Rigid Body component's Inertia Tensor value on the entity.
#public static bool AllowsSleep(Entity e)Reads the Rigid Body component's Sleep value of the entity.
#public static void SetAllowSleep(Entity e, bool value)Sets the Rigid Body component's Allow Sleep value on the entity.
#public static bool GetLockPositionX(Entity e)Reads the Rigid Body component's Lock Position X value of the entity.
#public static void SetLockPositionX(Entity e, bool value)Sets the Rigid Body component's Lock Position X value on the entity.
#public static bool GetLockPositionY(Entity e)Reads the Rigid Body component's Lock Position Y value of the entity.
#public static void SetLockPositionY(Entity e, bool value)Sets the Rigid Body component's Lock Position Y value on the entity.
#public static bool GetLockPositionZ(Entity e)Reads the Rigid Body component's Lock Position Z value of the entity.
#public static void SetLockPositionZ(Entity e, bool value)Sets the Rigid Body component's Lock Position Z value on the entity.
#public static bool GetLockRotationX(Entity e)Reads the Rigid Body component's Lock Rotation X value of the entity.
#public static void SetLockRotationX(Entity e, bool value)Sets the Rigid Body component's Lock Rotation X value on the entity.
#public static bool GetLockRotationY(Entity e)Reads the Rigid Body component's Lock Rotation Y value of the entity.
#public static void SetLockRotationY(Entity e, bool value)Sets the Rigid Body component's Lock Rotation Y value on the entity.
#public static bool GetLockRotationZ(Entity e)Reads the Rigid Body component's Lock Rotation Z value of the entity.
#public static void SetLockRotationZ(Entity e, bool value)Sets the Rigid Body component's Lock Rotation Z value on the entity.
#public static void SetPositionLocks(Entity e, bool x, bool y, bool z)Locks movement of a dynamic body along world X, Y and/or Z.
#public static void SetRotationLocks(Entity e, bool x, bool y, bool z)Locks rotation of a dynamic body around X, Y and/or Z.
Signatures
public static bool Has(Entity e) public static BodyType GetBodyType(Entity e) public static void SetBodyType(Entity e, BodyType value) public static bool IsEnabled(Entity e) public static void SetEnabled(Entity e, bool value) public static bool UsesGravity(Entity e) public static void SetUseGravity(Entity e, bool value) public static bool IsAwake(Entity e) public static void SetAwake(Entity e, bool value) public static float GetMass(Entity e) public static void SetMass(Entity e, float value) public static float GetLinearDamping(Entity e) public static void SetLinearDamping(Entity e, float value) public static float GetAngularDamping(Entity e) public static void SetAngularDamping(Entity e, float value) public static float GetGravityScale(Entity e) public static void SetGravityScale(Entity e, float value) public static Vector3 GetLinearVelocity(Entity e) public static void SetLinearVelocity(Entity e, Vector3 value) public static Vector3 GetAngularVelocity(Entity e) public static void SetAngularVelocity(Entity e, Vector3 value) public static Vector3 GetInertiaTensor(Entity e) public static void SetInertiaTensor(Entity e, Vector3 value) public static bool AllowsSleep(Entity e) public static void SetAllowSleep(Entity e, bool value) public static bool GetLockPositionX(Entity e) public static void SetLockPositionX(Entity e, bool value) public static bool GetLockPositionY(Entity e) public static void SetLockPositionY(Entity e, bool value) public static bool GetLockPositionZ(Entity e) public static void SetLockPositionZ(Entity e, bool value) public static bool GetLockRotationX(Entity e) public static void SetLockRotationX(Entity e, bool value) public static bool GetLockRotationY(Entity e) public static void SetLockRotationY(Entity e, bool value) public static bool GetLockRotationZ(Entity e) public static void SetLockRotationZ(Entity e, bool value) public static void SetPositionLocks(Entity e, bool x, bool y, bool z) public static void SetRotationLocks(Entity e, bool x, bool y, bool z)
KroysEngine 0.1.0 documentation, built from the engine repository by Tools/BuildDocsSite.py.