Restrict a player's movement to a path for a 2.5D game that has curved paths

There are some MMO games called "Fists of Fu" and "Elsword" that I was analyzing as I was trying to find recent examples of a 2.5d side scroller. There are points when the path "wraps around" a structure such as a mountain and although the path isn't straight, the character (and camera) rotates while making sure that the player still walks forward on that given. I'm assuming that only the player's X is being used for movement, but I don't know how I would make the character follow a path AND rotate accordingly.

alt text alt text

This PvP recording shows the rotation I was going for: http://www.youtube.com/watch?v=LiK6UPtYCBw&feature=related and http://www.youtube.com/watch?v=yhrZRbT-wEk&feature=related

So how are they accomplishing this? I assume that the player and camera are being rotated on the Y axis, but how does the system determine when, (or how) to rotate the player and make sure that the camera is always facing the player's side?

BTW: I'm Using the 2D Platforming Tutorial as a base..

Edit: I Imported the spline controller for the Unitycommunity wiki: http://www.unifycommunity.com/wiki/index.php?title=Spline_Controller and I can have an object move around the path, but that's all it does. It doesn't rotate the object to make it face a constant direction (forward vector logic needed possibly?)

I think the most effective and general purpose solution would be to use a Bezier Curve / 'Spline' interpolation technique -

Anything that interacts with the player would have something along the lines of:

var x : float;
var y : float;
private var spline : SplinePath;

function CalculatePosition() : Vector3 {
  return spline.WorldPosition( x ) + Vector3(0,y,0);
}

A SplinePath would consist of a series of points, and when you ask it for a position it will choose a point along a smooth path based on those points.

The idea is that .WorldPosition(x) will calculate the ground level at a certain "X" position in the level, then you'll add on any vertical changes your character has (jumping, etc).

Obviously the tough part of this is the SplinePath.WorldPosition function, but there are quite a few examples of this on the web. If I remember correctly there's a very nice Spline script available on the unity3d forums in the scripting section. If it's not exactly what you need, it'll be pretty close. Try searching for Spline or Bezier curve paths.

You might have a trigger that tells your camera and player that they are on a corner. Then maybe a distance check and/or dot product once they enter the trigger to determine the orientation of the camera and player...A trigger based system is probably the easiest to implement.

Just put an example together on the support site for iTween that I hope helps out with this. If you parent the camera to the character in this example and offset it from its right shoulder you will be able to have a camera that follows around curves. Hope it helps: http://itween.pixelplacement.com/examples.php

You should also take a look at iTween it has a few path interpolation options that migth help you out.

Hey there!

I’m the guy who created the spline system :slight_smile:

I believe that it should do exactly what you’re looking for. Oddly enough the code that I’m looking at doesn’t have a flag that I remember adding for whether to affect the object’s rotation. The default behavior should be to Lerp the object’s rotation so that it’s Z is looking down the spline in the direction that it’s moving.

Lines 197-204 in SplineController should do that. If they aren’t maybe your rotation damping value is at 0 for some reason? Let me know if you still can’t get this to work!

I’ve made camera system like game Pandemonium or Klonoa.Maybe this is the one you’ve been looking for, I made with iTween, so thanks to the guy behind iTween, Is Very Awesome!

link text