Forum rules - please read before posting.

Constrain player movements in ActionPlayerLocks.cs

edited March 12 in Technical Q&A

Hello everyone, I would like to constrain my character (direct control mode) to move in the horizontal direction. I would like to go through this menu
however, I don't see what to modify in the associated script.

https://ibb.co/jvKTVH1f
https://ibb.co/RTyn8G26

On the discord some one tell me to modifie this lines :

**`switch (doUpLock)
{
case LockType.Disabled:
KickStarter.player.upMovementLocked = true;
break;
...
}

switch (doDownLock)
{
case LockType.Disabled:
KickStarter.player.downMovementLocked = true;
break;
...
}
Change these lines to:

// Disable vertical movement
doUpLock = LockType.Disabled;
doDownLock = LockType.Disabled;

doUpLock = (LockType) EditorGUILayout.EnumPopup ("Up movement:", doUpLock);
doDownLock = (LockType) EditorGUILayout.EnumPopup ("Down movement:", doDownLock);**
`
But nothing is working.

Thx

Comments

  • What's the underlying issue that the Action doesn't solve? Locking the provided up and down movement directions will constrain the Player horizontally.

  • Yes, the idea is to block the character's movements only on the horizontal axis.

  • Chris, I was just wondering, is there some advantage to doing it this way rather than using the action list that does the same thing? (And definitely works for me)
  • The Action should allow for this - what is the specific issue you're having with it that requires you to make code changes?

  • I would like the character's movements to be always constrained on the horizontal and vertical axis and no longer go through the action list at the start of the room for example.

  • edited April 3

    Are you looking to have them avoid diagonal movement, or any vertical movement?

    Under Direct control during gameplay, constraining the up/down directions with the above Action will prevent up/down inputs from moving the Player. However, you'll need to set the Turning mode (in the Settings Manager's Movement panel) to Snap to avoid the character moving vertically when changing direction while walking.

    You can also use the Movement limitation option to prevent diagonal movement.

    This will not affect pathfinding, however - only user-controlled motion.

    To force the character to a given Y position, you can use a custom script that sets the Y value in LateUpdate. For more control, you can use a Spline that they snap to - an entry on the wiki allows for this:

    https://adventure-creator.fandom.com/wiki/Snap_characters_to_Splines

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.