Help with Collision Detection/Movement on Moving Platforms
Posted: Fri Jan 03, 2014 6:28 am
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:
everything falls apart. I tried this as a solution:
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!
(btw, controls are A/D to move, SPACE to jump, left click to toggle between physics mode and drag-and-drop mode.)
It works great when the shape is sitting still, but if you uncomment line 42:
Code: Select all
--platform:rotate(rotation*dt,centerX,centerY)
Code: Select all
local dist = math.sqrt(dx^2+dy^2)
if dist - oldDist > .5 then player:move(dx,dy) end
oldDist = dist
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!
(btw, controls are A/D to move, SPACE to jump, left click to toggle between physics mode and drag-and-drop mode.)