Skip to main content

Point

Points are what make the rigid bodies behave like real world entities. They are responsible for the movement of the RigidBodies and Constraints.

NOTE:

Points are handled by the Engine by default. Points are created for RigidBodies on creation. This class should only be used to create points for custom constraints and rigid bodies.

Use Engine:Create() to create custom points!

Types

type EngineConfig = {
gravity: Vector2,
friction: number,
bounce: number
}

type Canvas = {
topLeft: Vector2,
size: Vector2,
frame: Frame
}

type PointConfig = {
snap: boolean,
selectable: boolean,
render: boolean,
keepInCanvas: boolean
}

Functions

Point.new()

This method is used to initialize a new Point.

  • parameters - pos: Vector2, canvas: Canvas, engine: EngineConfig, config: PointConfig
  • returns - Point

Point:ApplyForce()

This method is used to apply a force to the Point. The time parameter can be passed in the function to apply the force for a certain time period.

  • parameters - force: Vector2, time: number | nil
  • returns - nil

Point:Update()

NOTE:

This method is automatically handled by the engine!

This method is used to apply external forces like gravity and is responsible for moving the point.

  • parameters - dt: number
  • returns - nil

Point:KeepInCanvas()

This method is used to keep the point in the engine's canvas. Any point that goes past the canvas, is positioned correctly and the direction of its flipped is reversed accordingly.

  • parameters - none
  • returns - nil

Point:Render()

NOTE:

This method is automatically handled by the engine!

This method is used to update the position and appearance of the Point on screen.

  • parameters - none
  • returns - nil

Point:Destroy()

Destroys the point's GuiObject, destroys the point's parent constraint (if any), and the point is no longer a part of the engine.


Point:SetRadius()

This method is used to determine the radius of the point.

  • parameters - radius: number
  • returns nil

Point:Stroke()

This method is used to determine the color of the point on screen. By default this is set to (RED) Color3.new(1, 0, 0).

  • parameters - color: Color3
  • returns nil

Point:Snap()

This method determines if the point remains anchored. If set to false, the point is unanchored.

  • parameters - snap: boolean
  • returns nil

Point:SetPosition()

Used to set a new position for the point

  • parameters - PositionX: number, PositionY: number
  • returns - nil

Point:SetMaxForce()

Determines the max force that can be applied to the Point.

  • parameters - maxForce: number
  • returns - nil

Fetch Methods

Point:Velocity()

Returns the velocity of the Point.

  • parameters - none
  • returns velocity: Vector2

Point:GetParent()

Returns the Parent (Constraint) of the Point if any.

  • parameters - none
  • return - parent: Constraint | nil

Point:GetNetForce()

Returns the net force acting on the point.

  • parameters - none
  • returns - netForce: Vector2

Properties

Position Vector2 (must-have)

The position of the point on screen.

Visible boolean

Whether or not the point is visible/being rendered on screen.

Snap boolean

Whether or not the point is anchored.

KeepInCanvas boolean

Whether or not the point will be able to go out of its confined canvas.

Radius number

The radius of the point.

Color number

The BackgroundColor of the point's frame.