Forum rules - please read before posting.

Restricting Z-Axis

Hello again,

I need a 2D Sprite that is attachted to a 3D collider to not be allowed to travel in the Z-axis (Up and Down movement) and only allow X axis movement (Left Right). Think 2D sprite platforming in 3D world space

I have attempted the following with no results

-Applying an action that constrains the characters up and down movement on startup. Works as intended but seems to have a curved effect meaning the more the character travels along the x-axis they also move in the Z as well. Its minor but causes the character to not travel in a strait line which causes major issues

-Attached a script forcing the character to be restrained at a set Z value. This cause the character to stutter along and isn't usual able. Disabling the Move with RigidBody? check makes it work but then causes the jump function to stutter like crazy.

I've noticed some others having issue with this but haven't seem to come to a solution.

Worse case scenario would be move over to playmaker to handle movement but I'd rather avoid that as much as possible and have AC do most of the heavy lifting to remove conflict and bugs.

Any help would be greatly appreciated

Comments

  • By "up and down", do you mean away from and towards the camera, as opposed to vertical movement?

    Applying an action that constrains the characters up and down movement on startup.

    Locking up/down movement with the Player: Constrain Action is akin to removing the "Vertical" input axis. It's up/down relative to the camera, not in world space.

    You could try toggling "Account for player's position on screen?", but it's also necessary to keep the camera pointing straight down the Z-axis.

    Attached a script forcing the character to be restrained at a set Z value.

    Are you applying the position in LateUpdate? It's not Unity-best-practice to force the position of a Rigidbody, but the Rigidbody itself has constrain options.

    AC currently requires control over these constraints (primarily to lock the rotation), but I'll look into how this may be optional so that you can check "Freeze Z Position" without inteference.

    Alternatively, you could consider replacing your Rigidbody and Capsule Collider with a Character Controller.

    Worse case scenario would be move over to playmaker to handle movement but I'd rather avoid that as much as possible and have AC do most of the heavy lifting to remove conflict and bugs.

    See the Manual's "Custom motion controllers" chapter as well as this tutorial. The exact needs of a custom motion control system will vary from project to project, but - done right - it shouldn't generally cause conflict or issues.

  • Update: I've looked into the Rigidbody option, and it should indeed be possible to allow for user-setting of the "Freeze Position" options as part of the next update.

  • By "up and down", do you mean away from and towards the camera, as opposed to vertical movement?>

    Correct

    Are you applying the position in LateUpdate? It's not Unity-best-practice to force the position of a Rigidbody, but the Rigidbody itself has constrain options.>

    Yes its applied via LateUpdate()

    Alternatively, you could consider replacing your Rigidbody and Capsule Collider with a Character Controller.>

    I'll give this a go

    See the Manual's "Custom motion controllers" chapter as well as this tutorial. The exact needs of a custom motion control system will vary from project to project, but - done right - it shouldn't generally cause conflict or issues.>

    I have made one but its still buggy and I was hoping to use the inbuilt controller.

    Update: I've looked into the Rigidbody option, and it should indeed be possible to allow for user-setting of the "Freeze Position" options as part of the next update.>

    This sounds exactly what I am looking for, I'll wait for the new update!

  • I'll wait for the new update!

    PM me if you'd like to be involved in testing.

  • For anyone having the same issue the latest update (1.67) has allowed restriction of Z-Axis and works fantastically. Many thanks to Chris for this!

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.