Skip to content

PhysicsAPI

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

Functions

void PhysicsAPI.OnHitEnter(function callback<YaEntity, YaEntity, number, float3>)

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>)

Fired when the entity has been hit by a character.
  • entity Entity
  • callback Callback function
    1. entity The entity that has been hit
    2. direction The direction in which the hit comes: 0 from the sides, 1 from the top, -1 from the down side
    3. point The normal of contact point

void PhysicsAPI.OnHitExit(YaEntity entity, function callback<YaEntity>)

Fired when the entity stops being hit by the character.
  • entity Entity
  • callback Callback function
    1. entity The entity that has been hit

void PhysicsAPI.OnTriggerEnter(function callback<YaEntity, YaEntity>)

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>)

Fired when the entity enters a trigger box.
  • entity Trigger
  • callback callback function
    1. entity The entity that enters a trigger box

void PhysicsAPI.OnTriggerExit(function callback<YaEntity, YaEntity>)

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>)

Fired when the entity exits a trigger box.
  • entity Trigger
  • callback callback function
    1. entity The entity that enters a trigger box

void PhysicsAPI.OnContactEnter(function callback<YaEntity, YaEntity>)

Fired when the rigidbody enters another entity.
  • callback Callback function
    1. rigidbody The rigidbody entity involved in this contact
    2. entity The entity involved in this contact

void PhysicsAPI.OnContactExit(function callback<YaEntity, YaEntity>)

Fired when the rigidbody exits another entity.
  • callback Callback function
    1. rigidbody The rigidbody entity involved in this contact
    2. entity The entity involved in this contact

void PhysicsAPI.OnContactEnter(YaEntity entity, function callback<YaEntity>)

Fired when the character enters another character or rigidbody.
  • entity The rigidbody entity
  • callback Callback function
    1. entity The entity involved in this contact

void PhysicsAPI.OnContactExit(YaEntity entity, function callback<YaEntity>)

Fired when the entity exits another character or rigidbody.
  • entity The rigidbody entity
  • callback Callback function
    1. entity The entity involved in this contact

void PhysicsAPI.AddForce(YaEntity entity, float3 force)

Applies a force to the rigidbody. Note: If called on the client side, the object may be inconsistent with the server
  • entity The rigidbody to apply a force to
  • force Force vector

void PhysicsAPI.AddImpulseForce(YaEntity entity, float3 force)

Applies an impulse to the rigidbody. Note: If called on the client side, the object may be inconsistent with the server
  • entity The rigidbody to applies an impulse.
  • force Force vector

void PhysicsAPI.AddTorque(YaEntity entity, float3 torque)

Applies a torque to the rigidbody. Note: If called on the client side, the object may be inconsistent with the server
  • entity The rigidbody to apply a torque.
  • torque Torque vector

void PhysicsAPI.AddForceAtPos(YaEntity entity, float3 force, float3 pos)

Applies a force at the specified position. Note: If called on the client side, the object may be inconsistent with the server
  • entity The rigidbody to apply a force
  • force Force vector
  • pos Global position vector

void PhysicsAPI.AddForceAtLocalPos(YaEntity entity, float3 force, float3 pos)

Applies a force at the specified local position. Note: If called on the client side, the object may be inconsistent with the server
  • entity The rigidbody to apply a force
  • force Force vector
  • pos Local position vector

void PhysicsAPI.AddLocalForceAtLocalPos(YaEntity entity, float3 force, float3 pos)

Applies a local force at the specified local position. Note: If called on the client side, the object may be inconsistent with the server
  • 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)

Applies an explosion at the specified position. Note: If called on the client side, the object may be inconsistent with the server
  • 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)

Sets the angular velocity. Note: If called on the client side, the object may be inconsistent with the server
  • entity The rigidbody to apply a force to
  • angVel The angular velocity vector

void PhysicsAPI.SetLinearVelocity(YaEntity entity, float3 linVel)

Sets the linear velocity. Note: If called on the client side, the object may be inconsistent with the server
  • entity The rigidbody to apply a force to
  • linVel The linear velocity vector

void PhysicsAPI.DisableGravity(YaEntity entity)

Disable the entity gravity
  • entity Rigidbody entity

void PhysicsAPI.EnableGravity(YaEntity entity)

Enable the entity gravity
  • entity Rigidbody entity

float3? PhysicsAPI.GetLinearVelocity(YaEntity entity)

ReturnsLinear velocity.
Gets the linear velocity.
  • entity Rigidbody entity

void PhysicsAPI.SetCollidable(YaEntity entity, boolean value)

Enables collisions on the entity. Note: If called on the client side, the object may be inconsistent with the server
  • entity Entity
  • value False if, collisions will be turned off

boolean PhysicsAPI.GetCollidable(YaEntity entity)

ReturnsGet collisions on the entity
Get collisions on the entity.
  • entity Entity

void PhysicsAPI.IgnoreCameraRaycast(YaEntity entity, boolean value)

Set whether the entity collides with the camera
  • entity Entity
  • value Value

YaQueryResult PhysicsAPI.RaycastSingle(float3 origin, float3 direction, YaQueryParameter parameter)

ReturnsQueryResult
Returns only the first entity contacted with the raycast.
  • origin The origin point of the raycast
  • direction The direction of the raycast
  • parameter YaQueryParameter

Array<YaQueryResult> PhysicsAPI.RaycastAll(float3 origin, float3 direction, YaQueryParameter parameter)

ReturnsList of QueryResult
Returns all the entities contacted with the raycast. Note that the order of the results is undefined.
  • origin The origin point of the raycast
  • direction The direction of the raycast
  • parameter YaQueryParameter

float3? PhysicsAPI.GetBoundsMinimum(YaEntity entity)

ReturnsBounds minimum
Returns the minimum value of the entity's physical bounding box
  • entity Entity

float3? PhysicsAPI.GetBoundsMaximum(YaEntity entity)

ReturnsBounds maximum
Returns the maximum value of the entity's physical bounding box
  • entity Entity

Array<YaEntity> PhysicsAPI.Overlap(float3 origin, YaQueryParameter parameter)

ReturnsEntity list
Queries for all entities in a certain area.
  • origin origin
  • parameter parameter