Skip to content

PhysicsAPI

Beta
PhysicsAPI is an interface which defines properties, events, and functions for objects which simulates physics.

Functions

PhysicsEntity PhysicsAPI.Physics(YaEntity entity)Beta
Instantiates a PhysicsEntity.
void PhysicsAPI.OnHitEnter(function callback<YaEntity, YaEntity, number, float3>)Beta
Fired when the entity has been hit.
  • callback callback function
    1. entity The entity that has been entered
    2. collider The entity that was hit
    3. direction The direction in which the hit comes: 0 from the sides, 1 from the top, -1 from the down side
    4. point the normal of contact point
void PhysicsAPI.OnHitEnter(YaEntity entity, function callback<YaEntity, number, float3>)Beta
Fired when the entity has been hit by a character.
  • callback callback function
    1. YaEntity The entity that has been hit
    2. int The direction in which the hit comes: 0 from the sides, 1 from the top, -1 from the down side
    3. float3 The normal of contact point
void PhysicsAPI.OnHitExit(YaEntity entity, function callback<YaEntity>)Beta
Fired when the entity stops being hit by the character.
  • callback callback function
    1. YaEntity The entity that has been hit
void PhysicsAPI.OnTriggerEnter(function callback<YaEntity, YaEntity>)Beta
Fired when the character enters a trigger.
  • callback callback function
    1. trigger The entity that has been entered
    2. entity The entity involved in this collision
void PhysicsAPI.OnTriggerEnter(YaEntity entity, function callback<YaEntity>)Beta
Fired when the entity enters a trigger box.
  • callback callback function
    1. YaEntity The entity that enters a trigger box
void PhysicsAPI.OnTriggerExit(function callback<YaEntity, YaEntity>)Beta
Fired when the character exit a trigger.
  • callback callback function
    1. trigger The entity involved in this collision
    2. entity The entity that has been entered
void PhysicsAPI.OnTriggerExit(YaEntity entity, function callback<YaEntity>)Beta
Fired when the entity exits a trigger box.
  • callback callback function
    1. YaEntity The entity that enters a trigger box
void PhysicsAPI.OnContactEnter(function callback<YaEntity, YaEntity>)Beta
Fired when the character enters another character or rigidbody.
void PhysicsAPI.OnContactExit(function callback<YaEntity, YaEntity>)Beta
Fired when the character exits another character or rigidbody.
void PhysicsAPI.OnContactExit(YaEntity entity, function callback<YaEntity>)Beta
Fired when the entity exits another character or rigidbody.
void PhysicsAPI.AddForce(YaEntity entity, float3 force)Beta
Applies a force to the rigidbody.
  • entity The rigidbody to apply a force to
  • force Force vector
void PhysicsAPI.AddImpulseForce(YaEntity entity, float3 force)Beta
Applies an impulse to the rigidbody.
  • entity The rigidbody to applies an impulse.
  • force Force vector
void PhysicsAPI.AddTorque(YaEntity entity, float3 torque)Beta
Applies a torque to the rigidbody.
  • entity The rigidbody to apply a torque.
  • torque Torque vector
void PhysicsAPI.AddForceAtPos(YaEntity entity, float3 force, float3 pos)Beta
Applies a force at the specified position.
  • entity The rigidbody to apply a force
  • force Force vector
  • pos Global position vector
void PhysicsAPI.AddForceAtLocalPos(YaEntity entity, float3 force, float3 pos)Beta
Applies a force at the specified local position.
  • entity The rigidbody to apply a force
  • force Force vector
  • pos Local position vector
void PhysicsAPI.AddLocalForceAtLocalPos(YaEntity entity, float3 force, float3 pos)Beta
Applies a local force at the specified local position.
  • entity The rigidbody to apply a force
  • force Local Force vector
  • pos Local position vector
void PhysicsAPI.AddExplosionImpulseForce(YaEntity entity, number explosionForce, float3 explosionPosition, number radius, number upwardsModifier)Beta
Applies an explosion at the specified position.
  • entity The rigidbody to apply an explosion
  • explosionForce The force of the explosion
  • explosionPosition The centre of the sphere within which the explosion has its effect
  • radius The radius of the sphere within which the explosion has its effect
  • upwardsModifier Adjustment to the apparent position of the explosion to make it seem to lift objects
void PhysicsAPI.SetAngularVelocity(YaEntity entity, float3 angVel)Beta
Sets the angular velocity.
  • entity The rigidbody to apply a force to
  • angVel The angular velocity vector
void PhysicsAPI.SetLinearVelocity(YaEntity entity, float3 linVel)Beta
Sets the linear velocity.
  • entity The rigidbody to apply a force to
  • linVel The linear velocity vector
float3? PhysicsAPI.GetAngularVelocity(YaEntity entity)Beta
Gets the angular velocity.
float3? PhysicsAPI.GetLinearVelocity(YaEntity entity)Beta
Gets the linear velocity.
void PhysicsAPI.ResetPositionAndRotation(YaEntity entity, float3 pos, quaternion rotate, boolean clearVelocity)Beta
Resets the position and rotation of the entity.
  • clearVelocity Ignore physics velocity on entity
void PhysicsAPI.SetCollidable(YaEntity entity, boolean value)Beta
Enables collisions on the entity.
boolean PhysicsAPI.GetCollidable(YaEntity entity)Beta
Get collisions on the entity.
void PhysicsAPI.IgnoreCameraRaycast(YaEntity entity, boolean value)Beta
Set whether the entity collides with the camera
void PhysicsAPI.SetPhysicsLayer(YaEntity entity, number value)Beta
Set the entity physics layer
number PhysicsAPI.GetPhysicsLayer(YaEntity entity)Beta
Get the entity physics layer
void PhysicsAPI.CollisionGroupSetCollidable(number layer0, number layer1, boolean value)Beta
Sets the collision state between two layers
boolean PhysicsAPI.CollisionGroupGetCollidable(number layer0, number layer1)Beta
Gets the collision state between two layers
boolean PhysicsAPI.InTrigger(YaEntity entity, YaEntity trigger)Beta
Checks if the entity is in the Trigger box.
  • entity The entity to check
  • trigger The trigger
YaQueryResult PhysicsAPI.RaycastSingle(float3 origin, float3 direction, YaQueryParameter parameter)Beta
Returns only the first entity contacted with the raycast.
  • origin The origin point of the raycast
  • direction The direction of the raycast
  • parameter YaQueryParameter
float3? PhysicsAPI.GetBoundsMinimum(YaEntity entity)Beta
Returns the minimum value of the entity's physical bounding box
float3? PhysicsAPI.GetBoundsMaximum(YaEntity entity)Beta
Returns the maximum value of the entity's physical bounding box
YaEntity[] PhysicsAPI.Overlap(float3 origin, YaQueryParameter parameter)Beta
Queries for all entities in a certain area.
  • origin origin