Skip to content

Commit

Permalink
Rework player collider to help mitigate #44
Browse files Browse the repository at this point in the history
  • Loading branch information
SirLynix committed Nov 20, 2020
1 parent 43d4dfc commit bf7a8f9
Showing 1 changed file with 6 additions and 30 deletions.
36 changes: 6 additions & 30 deletions scripts/entities/burger/shared.lua
Original file line number Diff line number Diff line change
Expand Up @@ -172,41 +172,17 @@ entity:On("init", function (self)

-- Note that some positions are adjusted to prevent getting stuck

local colliderOffset = 2
local bottomColliderSize = 2

local colliders = {
{
-- Bottom
-- Adjust offsets to prevent
Collider = Segment(bottomLeft + Vec2(colliderOffset, 0), bottomRight - Vec2(colliderOffset, 0)),
Friction = 0,
FromNeighbor = topLeft,
ToNeighbor = topRight
},
{
-- Right side
Collider = Segment(bottomRight - Vec2(0, colliderOffset), topRight),
Friction = 0,
FromNeighbor = bottomLeft,
ToNeighbor = topLeft
},
{
-- Top
Collider = Segment(topRight - Vec2(colliderOffset, 0), topLeft + Vec2(colliderOffset, 0)),
Friction = 1,
FromNeighbor = bottomRight,
ToNeighbor = bottomLeft
},
{
-- Left side
Collider = Segment(topLeft, bottomLeft - Vec2(0, colliderOffset)),
Friction = 0,
FromNeighbor = topRight,
ToNeighbor = bottomRight
-- Movement collider (bottom)
Collider = Rect(bottomLeft - Vec2(0, bottomColliderSize), bottomRight),
Friction = 0
},
{
-- Internal cube (helps with high-speed collisions)
Collider = Rect(topLeft + Vec2(colliderOffset, colliderOffset) * 2, bottomRight - Vec2(colliderOffset, colliderOffset) * 2),
-- Main collider
Collider = Rect(topLeft, bottomRight - Vec2(0, bottomColliderSize)),
Friction = 0
}
}
Expand Down

0 comments on commit bf7a8f9

Please # to comment.