I am working on a platformer, which has detailed maps and landscapes. But the problem is, that I can't get the Player to stay on top of the platform/ground. The platforms are ramped, sometimes even curved. The player just seems to walk straight through the ramps (until too deep to proceed), and shakes when walking down a ramp. And most importantly, when the player jumps, and lands on the platform, part of him sinks into the ground.
A simple _root.Player._y--; won't work, because the player is shaking by just touching the platform.
There are no specific geometric measurements, but rather drawn landscapes with irregular shapes.
How could I make the instance "Player" always stay on the top of the instance "Platform".
One more note: The Platform instance is many platforms put into one, so there will be platforms above platforms.
well... it's really difficult to come up with a solution for you here without a great deal more information about the code your using. this is a typical problem in collision detection, and it is a complex one.
basically you need to test radially about the player, using a shape-based hit test operation, (although you can also use a bitmap shape based system rather than a radial one, but it is more computationally expensive) when a contact point is found you then need to find the normal to the plane at the contact manifold and 'ush' the player in that direction, often in physics engines, the contact is stored and continually referenced in order to respond appropriately (keeping the shaking from happening) - in fact there is usually an array of contacts, to process in order to compute the net forces currently being applied to the object and will often use verlet or Euler integrations <- forms of differential calculations.
so... it's a pretty complex issue when using irregularly shaped platforms, slopes or curves. unless you are a math wiz, or interested in building a basic physics engine yourself, you may want to opt to use an out-of-the-box solution/physics engine, like Box2D or APE or several others.
It is possible to have an invisible line coming from the player downwards, and stops where the top of the platform is, and detect the y value from the collision point? Basically, have rays?
I don't want to make it too complex, unless I have to.
kinda - but you don't need to use a line, a point or vector in space will do, based from the instance registration point (usually at center). but you are talking about something that is the subject of countless experiments and methodologies - and it is complex.
basically, it depends on *when* you make the test. often a good place is before the character is too far within the bounds of the object, keeping it out - but it is very difficult to determine without a great deal more information about your code, and structure. usually, a simple method goes something like this:
where p is your player instance, bound is the platform, and rateX/Y is the speed of movement.
BUT this doesn't really take into account slopes and curves - to do that you must check a *radial* distance about the player, and when you find a point of contact, move in a direction opposing that particular angle. so there is much more to it than the above example.