Entity
Provides properties and functions to interact with an Entity in the world.
Properties
isEntity
Indicates whether the object is an Entity. This property is read-only.
name
Gets the name of the entity. This property is read-only.
id
Gets the ID of the entity — every entity in the world has a unique ID. This property is read-only.
entityId
Gets the code (a string value) used to identify the type of the entity. This can be used to spawn copies of an entity. This property is read-only.
useGravity
Determines whether the entity is affected by gravity.
isKinematic
Determines whether physics affects the entity.
velocity
Gets or sets the velocity of the entity.
angularVelocity
Gets or sets the angular velocity of the entity (measured in radians per second).
drag
Gets or sets the drag factor of the entity. Drag determines the amount of resistance applied to the linear motion of the entity. This can be used to slow down an entity — the higher the drag, the more slowly an entity moves.
angularDrag
Gets or sets the angular drag factor of the entity. Angular drag determines the amount of resistance applied to the rotational motion of the entity. This can be used to slow down rotation of an entity — the higher the drag, the more slowly an entity rotates.
position
Gets or sets the current position.
rotation
Gets or sets the current rotation (in degrees).
scale
Gets or sets the current scale.
networkId
Gets the network ID of the object. This property is read-only.
onDestroy
Assigns a function that will be called when the object is destroyed. This property is write-only.
onSensorEnter
Assigns a function that will be called when an object enters the sensor. This property is write-only.
onSensorExit
Assigns a function that will be called when an object leaves the sensor. This property is write-only.
Functions
addForce(force, forceMode)
Applies a force to the entity.
Parameters
- force — The force vector. E.g. {0,1,0} for a force in the vertical 'up' direction.
- forceMode — The ForceMode.
addTorque(force, forceMode)
Applies a torque force to the entity.
Parameters
- force — The torque vector. E.g. {0,1,0} for a torque that turns the entity anti-clockwise around the y-axis.
- forceMode — The ForceMode.
destroy()
Destroys the object.