Lock Rigid Body movement to one axis

I mean all that needs to happen is somehow give the rigidbody (if that method was done) the safe margin like the character body has and it’d be perfect. Though let me try what DragonForge just said and see if that works.

1 Like

How do you prevent pushing diagonally? You need some localized guards so it’s not a generalized solution.

Locking rotation just does that, unless the player moves diagonally which in most cases would be fine. you’d have to move diagonally for it to push diagonally.

Locking rotation just locks rotation. It doesn’t prevent diagonal pushes.

You create paths that don’t allow it.

If you want a wide open space, then yeah, you need your code if you want it to make it feel like old school Zelda.

I guess I should probably actually try showing what I’m trying to avoid:

Hope its noticeable enough but whenever I push it up and down, it moves slightly due to the inaccuracy of the collisions that should contain it, as they aren’t exact.

I’m not even sure if its even possible to overcome that.

If not, I’ll either just leave it in or make the rock’s y collision box smaller so that it can intetionally wiggle.

TBH I’d call that a feature. Makes it feel like the player has a little more control than they do.

1 Like

Of course it’s possible… if you do it kinematically, exactly as I did in the example I posted. Don’t avoid it just because you might not fully understand what the code is doing.

The question is, do you need a generalized solution or just this slide between two end positions along a rail.

You haven’t described your use case precisely enough.

1 Like

Well, instead of just pushing left and right I intend on making more complex puzzles with it than just push rock right.

Also I’m pretty sure I understand your example, its just the rock liked to jitter even with physics interpolation on. It never did it all the time but it happened. Give me a moment and I’ll record that too.

Here’s a piece of advice about “jitters”. Don’t obsess over them until you have all the graphics of the final game on your screen. If at that point you still perceive “jitters” - then go deal with them.

2 Likes

Also when I bump into it from the top or bottom, it significantly slows down. It happens in the video and I don’t even know how I bumped it.

Oh I guess framerate is too low to show it here but yeah.

Also yeah thats fair. I guess I did just waste a day obssessing over something that doesn’t affect gameplay.

There’s something else causing it. Have you tried my code in a clean minimal scene?

no actually. I gotta eat first but then I’ll try that.

Well that’s the first thing you should have tried.

1 Like

Just did so and while it is much much less noticeable, it still exists, which why it might be so pronounced in mine may be a combination of the camera moving, and a much smaller window size.

I guess I’m chasing something that isn’t possible right now, and honestly I don’t need to spend this much time for something so trivial. Thank you for your time, and I am sorry the answer after these hours we spent ended up being “imma just deal with it” but I think I have spent too much time on this single detail. I guess I’ll leave this open just in case a breakthrough happens but for now, I’ll be taking my leave.

Why did I phrase it so seriously lol

1 Like