Player

Player extends Object, adding functions and properties to it.
Player is not creatable, there's only one instance of it. It can only be accessed through its globally exposed variable.

Player is a shortcut to Client.Player.

Represents the local Player.

Functions

nil AddChild ( Object child )

Adds given Object as a child.

Object extensions like Shape or MutableShape are naturally accepted too.

local o = Object()
local myShape = Shape(Items.someuser.someitem)
o:AddChild(myShape)

Casts a ray from player's position, returns an Impact if it hits something, nil otherwise.

local impact = Player:CastRay()
if impact ~= nil then
	print(impact)
end
nil EquipBackpack ( Item item ) coming soon

Equips an Item, Shape or MutableShape on the back of the Player.
You can remove what's been equiped using nil argument

nil EquipHat ( Item Item ) coming soon
nil EquipHat ( Shape shape )

Equips an Item, Shape or MutableShape on Player's head.
You can remove what's been equiped using nil argument

Puts an Item, Shape or MutableShape in Player's left hand.
You can remove what's been equiped using nil argument

Puts an Item, Shape or MutableShape in Player's right hand.
You can remove what's been equiped using nil argument

Config = {
  Items = { "aduermael.rainbow_sword" }
}

Client.OnStart = function()
  Player:EquipRightHand(Items.aduermael.rainbow_sword)
  -- or
  local s = Shape(Items.aduermael.rainbow_sword)
  Player:EquipRightHand(s)

  Player:EquipRightHand(nil) -- unequips the sword
end
nil GetChild ( integer index )

Get child Object at index.

if o.ChildrenCount > 0 then
  print(o:GetChild(1)) -- prints first child
end

Converts a local position to world coordinate system.

local p = Number3(1, 2, 3)
local pInWorldCoords = myObject:PositionLocalToWorld(p)

Converts a world position to local coordinate system.

local p = Number3(1, 2, 3)
local pInLocalCoords = myObject:PositionWorldToLocal(p)

Unsets parent/child relationship with child parameter. The child ends up being deleted if it has no other references.

o:RemoveChild(someChildObject)

Unsets parent/child relationship with all children. Individual children end up being deleted if they have no other references.

o:RemoveChildren()

Removes the Player from its parent. Doesn't do anything if the Player has no parent.

o:RemoveFromParent()

Converts a local rotation to world coordinate system.

Converts a world rotation to local coordinate system.

nil SetParent ( Object parent )

Sets parent/child relationship with parent parameter. nil can be used to remove the Object from its parent.

local o = Object()
o:SetParent(Map) -- o is now a child of the map
-- (Map is an extension of Object)

Swaps Player's hand held items.
If one hand holds nothing, the Item switches hands.

Properties

Player's continuous acceleration.

Default value: {0,0,0}.

⚠️ Acceleration is nil and can't be set if Player.Physics is false.

-- Acceleration can be used to compensate gravity: 
myObject.Acceleration = -Config.ConstantAcceleration
-- myObject's acceleration is now the invert of 
-- Config.ConstantAcceleration, cancelling it.

Backward is a unit vector (vector with a length of 1). It determines which direction is "backward" for the Player.

Setting it is a way to rotate the Player.

Returns the block on which the Player is standing on.

Returns an array of Blocks the player is standing on

local blocks = Player.BlocksUnderneath
for index, value in ipairs(blocks) do 
    -- greenColorIndex is a block previously defined
    local newBlock = Block(10) -- 10: BlockerProperties index
    value:Replace(newBlock)
end

Returns number of child Objects.

Down is a unit vector (vector with a length of 1). It determines which direction is "down" for the Player.

Setting it is a way to rotate the Player.

Forward is a unit vector (vector with a length of 1). It determines which direction is "forward" for the Player.

Setting it is a way to rotate the Player.

Unique player ID for played game. A different ID can be attributed after reconnection.

Can be set to true for the Player to be hidden.
Nothing else changes, the Player remains in the scene and it keeps being affected by the simulation (collisions, etc.).

boolean IsOnGround read-only

true when the Player is not falling.

⚠️ IsOnGround only makes sense when Player.Physics is true.

Left is a unit vector (vector with a length of 1). It determines which direction is "left" for the Player.

Setting it is a way to rotate the Player.

Position of the Player in its parent.
In other words, LocalPosition refers to the position of the Player relative to the {0,0,0} position of its parent.

Rotation of the Player in its parent.

Nested Object local rotations are combined to obtain the "world rotation" (Object.Rotation), the Object's final on-screen rotation.

Scale of the Object, in its parent.

Nested Object local scales are combined to obtain the "world scale" (Object.Scale), the Object's final on-screen scale.

myObject.LocalScale = 2 -- the Object is now 2 times bigger
topLevelObject.LocalScale = 2
local o = Object()
o.LocalScale = 0.5
topLevelObject:AddChild(o) -- o becomes a child of topLevelObject
-- o ends up being displayed with a scale of 1
number LossyScale read-only

Convenience property that attempts to match the actual world scale as much as it can.

Be aware, this Motion property is a hack regarding laws of physics. (sorry Isaac)

But it's very practical to move objects without worrying about forces at play.

This is what's being used by default when you're moving around with your avatar (see Client.DirectionalPad). It's the reason why you can stop moving horizontally while in the air.

Basically, Motion is a constant velocity that's added to Player.Velocity each frame to obtain the final movement. (Player.Velocity value is not impacted)

Motion is expressed in world coordinates.

⚠️ Motion is nil and can't be set if Player.Physics is false.

local speed = 10
myObject.Motion = Camera.Forward * speed
-- myObject will move in the same direction the camera is currently facing.
-- If the Camera rotates after this, it won't change where myObject is heading.

Turns physic simulation on/off when set.

⚠️ When turned on, Player.Velocity & Player.Motion are set to {0,0,0}.

Absolute world position of the Player.

local o = Object()
-- places the object where the local player is
o.Position = Player.Position

Right is a unit vector (vector with a length of 1). It determines which direction is "right" for the Player.

Setting it is a way to rotate the Player.

Player's rotation. (Y value is not considered)

local o = Object()
o.Rotation = {0, math.pi, 0}
-- o revolved half a turn on Y axis

-- another way to rotate the object:
o.Forward:Rotate({0, 0, math.pi / 2})
o.Forward = Camera.Forward

Up is a unit vector (vector with a length of 1). It determines which direction is "up" for the Player.

Setting it is a way to rotate the Player.

Player's account username. Usernames are unique.

Player's velocity (speed + direction).

-- makes myObject jump:
myObject.Velocity.Y = 100