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 GetChild ( number index )

Get child Object at index.

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

Gives an item to the Player. The parameter has to be an holdable item. (items can be browsed in the gallery)

Import("aduermael.rainbow_sword")

Player:Give(R.aduermael.rainbow_sword)

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)

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
number ChildrenCount read-only

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.

true when there's a block right underneath Player's feet.

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

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:Rotate({0, 2, 0})
-- o rotated 2 radians arount Y axis

-- another way to rotate the object:
o.Forward = {0, 0, 1}
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