I'm trying to make a game with Phoenix so I'm testing some stuff with entities and collision to find a setup that works for my game. I've written some code that works pretty well except for one problem.
I've uploaded a
7zip with a small example since that's the easiest way to illustrate the problem. It's a simple platform example with a character and 3 platforms. The platforms are meant to be completely solid (You can't jump through them like in many other platform games). It works pretty well except if you hit the platform from the right. If you hold the left arrow key down and hits a platform from the right you'll get stuck in the platform slowly falling down.
I've tried but can't see what's wrong with my code.
This is the code that handles the horizontal movement/colliding:
[pascal]
Body.Displacement := Vector2f(MoveSpeed * FrameTime, 0);
if World.Collide2(Body, Collisions) then
begin
Collisions.SortByTime;
if Collisions[0].Body.CollisionGroup = COLLISION_GROUP_2 then
begin
Body.Displacement := VectorMul(Collisions[0].Distance, 0.99);
end;
end;
Body.MoveToDisplacement;
[/pascal]
Is there something I've misunderstood about the collision system or is there perhaps a small bug in the Phoenix code?
Bookmarks