# Sprite Kit - keeping character level with the terrain 2d endless runner

I've been trying to figure this out exhaustively for the past few days and still haven't found an answer. I have an endless runner built using swift where the character is fixed and the terrain moves to the left. I have edge physics bodies on the terrain, and edge physics bodies that go up and down slopes.

The problem is, if I want my character to collide with the ground without being pushed back by it, since the only thing that can make contact with an edge is a dynamic volume.

My goal is to keep the character level with the terrain, (assuming they're not jumping). Even on slopes.

I've tried ray casting using enumeratebodiesalongraystart, but can't seem to figure out how to get coordinates of where it intersects with the ground. I've tried having an edge body that is vertical, that intersects with the ground(two edge bodies cannot make contact in sprite kit). I've tried dynamic volumes. I've tried Static volumes. Nothing works. I'm not posting code here since I'm really just looking for a general answer to sort of point me in the right direction, but I'm coding in swift. Thanks in advance. Also I have the character in a different bitmaskcatagory than the terrain catagory and they are set up to recognize each other, and do if one of them is a dynamic volume physics body.

• I'm still a bit unclear on what the problem is. What does "collide with the ground without being pushed back" mean? Could you explain the particular situation where it's not working how you expect? – Anko Apr 28 '15 at 12:46
• Fair enough. Basically, I want there to be a contact without a collision. So if two edge physics bodies cant make a contact then it would have to be a static volume body, though, that doesn't seem to register a contact either. If I add a dynamic volume to the sprite, it is pushed to the left by the terrain that is moving left due to the built in physic simulation. I'm wanting the player sprite to be fixed in one x position while moving up and down as the terrain height changes. – tedesignz Apr 28 '15 at 14:13

character.constraints = [SKConstraint.positionX(SKRange(constantValue: 0.0))]