Nape Physics: Collision issue (moving across tiles)

40 views
Skip to first unread message

Snky Games

unread,
Oct 16, 2018, 2:31:58 PM10/16/18
to Nape Physics
Hello,

There is a character, when moved across one tile to another sometimes the character either jumps over the meeting point of the tile polygons or becomes completely stuck and can no longer move in the direction they were going until they take a step back.
( video of issue: https://www.youtube.com/watch?v=wLAAHyinOVE )
( Interactive demo of issue: http://snkygames.com/InputSceneTest )

Has anyone else met with this issue? Any solution suggestions.

The issue still occurs if I allow body rotation.
The issue still occurs if I use a rectangle as a polygon instead of a circle.

Code:

//character
//material: elasticity=0.650, frictionDynamic=0.570, frictionStatic=1.200, density=1.000, frictionRolling=0.000
<body>.shapes.add(new Circle(16, null, <material>));
var vel:Vec2 = <body>.velocity;
<body>.velocity = Vec2.weak(vel.x + +/-2000.000 * 0.020, vel.y + 0.000);

/
/nape
<gravity> = new Vec2(0.000, 400.000);
<space>.step(***, 10, 10);

//rectangle tile
//material: elasticity=0.000, frictionDynamic=1.000, frictionStatic=1.000, density=1.000, frictionRolling=0.000
<body>.shapes.add(new Polygon(Polygon.box(<width>, <height>), <material>));

T1m_

unread,
Dec 9, 2018, 6:58:00 AM12/9/18
to Nape Physics
As I understood you are using a shape per tile. This is a bad idea. You get what you get because of that approach. Character's shape collides with VERTICAL edge of a tile (see below how Nape sees such a situation)
thus your character cant move.

What you can do:
- Charracter's body should have circle "legs" with angular velocity during movement (the good one solution).
 OR
- Don't use shape-per-tile. Write an algorithm which builds solid rectangular shape to cover an entire row/column of tiles (the best solution IMO).
 OR
- Cancel collision and slightly push forward your character when this bad collision does happen (the tricky one, but could work out). Read more about it in Nape manual .
Reply all
Reply to author
Forward
0 new messages