Will be answered

Side Scroller Lock Axis

itsthehawke 10 months ago in Traversal updated by Marti (Lead Developer) 4 months ago 11

Working on a 2.5D side-scroller at the moment and a problem I keep running into is when a character collides with an object, it can adjust his position on the X axis, which breaks the whole point of side-scroller.

Is there a way to fix the character on a given axis?

Unity version:
Game Creator version:
Under review


Not sure I fully understood your question. The If you set the Player's Input to Side-Scroll it should stick to that plane axis. Can you post a screenshot or give some more details about the issue?

The original axis the side-scroller is running on (Green) will get adjusted when I collide (in this case - slide) object that has a slope with high angle and will fall down to the ground on a new, adjusted axis (yellow).

I understand this is a normal behaviour of the Unity physics engine and it makes sense for it to happen, but it limits my possibilities greatly.

Ofcourse Im not putting objects like these into the scene, but this happens with any movable object that the character can collide with + all the ragdolls of enemies that act really crazy on collision with the player, also changing the position on the axis.

This means I can't have any objects with rigidbodies I want my character to collide with + I will need to disable player collision with enemy ragdolls because when Player jumps on an enemy ragdoll, it is going to move him very rapidly and the ragdoll itself will jump around the location like there is a huge force applied to it (possibly another bug?).

Hmm correct. I'll open a ticket and have a look at it. It may be possible to enable/disable axis snapping. Thanks for pointing this out!

Will be answered

Hi Itsthehawkeye;

I've been working on this a big part of this morning, but there isn't a simple solution to solve this. Basically because the conflict between the sliding mechanic and the side-scroll. We could allow the character to snap to an axis, but after the player releases the input, the character would be susceptible to change its axis plane.

We'll leave the ticket open, but this requires a good chunk of our core character movement system to be redone, and it's not a top priority at the moment. Sorry for the bummer. I'll circle back in the future when we have the time to take a closer look.

Hi, I find a workaround, but you need to change the PlayerCharacter.cs, and it may not be highly recommended, but it works!

you must change the UpdateInputSideScroll:

protected virtual void UpdateInputSideScroll(Vector3 axis)
Vector3 targetDirection = Vector3.zero;
if (!this.IsControllable()) return;

if (Application.isMobilePlatform || TouchStickManager.FORCE_USAGE)
Vector2 touchDirection = TouchStickManager.Instance.GetDirection(this);
targetDirection = axis * touchDirection.x;
targetDirection = axis * Input.GetAxis(AXIS_H);

Camera maincam = this.GetMainCamera();
if (maincam == null) return;


float invertValue = (this.invertAxis ? -1 : 1);
Vector3 moveDirection = Vector3.Scale(this.direction, axis * invertValue);

Vector3 Xpoint = this.characterLocomotion.GotoPoint; // TRL Add this if you create a new vector3 in the player's character menu, but you can correct the z-line by code directly.

if (this.transform.position.z != Xpoint.z)//TRL-- the player, and all the characters will always go to this z-line
moveDirection = moveDirection + new Vector3(0, 0, Xpoint.z - this.transform.position.z);


moveDirection *= this.direction.magnitude;



You can edit the menu and add a float to give to the script the z point or add a vector3 like me. Or if you always work on the same z-line fix it by code, but I don`t recommend do that. The best is to use variables to control the exact position of your character.

just an appreciation, you should use x instead of z but it works the same.

Thanks Tomás! You're right that this works, but there are a few cases where it fails. When the Player (your code only works with the Player but could be changed to work for any character) is locked on a specific plane, it only does when it moves.

When there's no "force" being applied to a character, this can freely drift through ramps. Unfortunately, there's no way for us to easily lock the character on a plane at all times.

Thanks though for pointing this out! :-) 


Thank you for chiming in on the issue gentlemen! Much appreciated.

I'm running into this issue as well, which I don't when using a RigidBody on the Player instead of a Character Controller. Would it be possible to create a second type of Player object, specifically for Side Scroll projects, that uses the RigidBody instead? This might be an easier solution than changing your original Player object.

It might even mean creating a separate module for Side-Scroll projects since it would mean new Player Objects, new Character Objects, and could include some other common side-scroll mechanics like wall jumping, ledge hanging, etc.


I tried this and got this error.

Assets\Plugins\GameCreator\Characters\Mono\Characters\PlayerCharacter.cs(242,55): error CS1061: 'CharacterLocomotion' does not contain a definition for 'GotoPoint' and no accessible extension method 'GotoPoint' accepting a first argument of type 'CharacterLocomotion' could be found (are you missing a using directive or an assembly reference?)

I'm sure its because I haven't defined the goto in the menu. How do I do that?

You need to modify the code as Tomás code. The GotoPoint method is not defined by default.