Help with Collision Detection/Movement on Moving Platforms

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
ryanwb2
Prole
Posts: 1
Joined: Fri Jan 03, 2014 5:57 am

Help with Collision Detection/Movement on Moving Platforms

Post by ryanwb2 »

With the aid of Hardon Collider, I've been making a physics engine for a game I'm working on, wherein the world consists of various polygons that the player can walk on. Using Hardon Collider's escape vector, or whatever you call it (the dx and dy in the onCollide function) and some algebra, I've come up with a system that computes the slope of the line and lets the player walk up it smoothly if it's not too steep, and slide down it if it is.
It works great when the shape is sitting still, but if you uncomment line 42:

Code: Select all

--platform:rotate(rotation*dt,centerX,centerY)
everything falls apart. I tried this as a solution:

Code: Select all

local dist = math.sqrt(dx^2+dy^2)
if dist - oldDist > .5 then player:move(dx,dy) end
oldDist = dist
but it's really spazzy and weird and probably prone to all sorts of horrible glitches.
So I guess what I'm asking is for some advice on how I should handle moving/rotating platforms like this, without making the character teleport around like a moron!
I put the .love file here, because the board here is saying it's full or something. I apologize in advance for how sloppy and confusing my code probably is, and I'd really appreciate any kind of pointers anyone could give me! :awesome:
(btw, controls are A/D to move, SPACE to jump, left click to toggle between physics mode and drag-and-drop mode.)
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests