Hey all.
So this may seem like yet another movement question, but I’d like to think it’s fair enough, because despite my efforts, I haven’t quite found what I need.
I have seen MANY movement scripts around, both here and elsewhere like on Unify. There are a few problems, though, related to them – namely that many of these were done before 2D was implemented (and yes, I know that shouldn’t technically matter for the coding but still… ), and even though many were done after as well, I seem to run into similar issues.
A brief explanation of what I want:
I want to be able to move my character along the X and Y axis, as is common (given Unity’s Z axis) in old school RPGs like the older FFs and well, pretty much every turn-based RPG from more than 15 years ago. (Pokemon is another good example if you’re still unsure of what I mean)
I optionally want the option to be able to move in a grid like manner, but not through just teleporting from one spot to another, rather actually physically moving to it (again, like Pokemon), but if that presents issues, then I can live with diagonal and non-grid movement.
Finally, I want to actually collide with objects and stop to a stand still. No jittering or phasing through the colliders (that may seem obvious, but I will elaborate why I’m saying that).
What I keep running into:
Most movement scripts I find for this type are mostly based around side-view scrollers and employ jumping. I also see rotation used because of top-down shooters and the like, but when I dissect the code I still don’t get something usable because…
It’s usually two things that end up happening. One: I don’t have grid movement scripts that are working as intended to actually toy with and see what’s happening – so even though it’s an optional thing for me, I’m a little eh about not having much to look at so I can learn (incredibly visual learner when it involves code), and Two: When they do move, they completely ignore colliders. I have a theory that there is a higher level technique to employ that helps check for that, but I’ve yet to see it.
Finally, colliders in general have been super weird for me. Many of the scripts I test out have me sticking to the colliders or still phasing through them. I NEVER get stopped by the collider. I either jitter, or I go through it eventually.
What I do:
Now, I am fairly new, but I think I’m correct in saying that in order to get your standard collision, you use a Rigidbody2D (correct for gravity), and a boxCollider2D on your character, and a simple collider of whatever sort on your wall or statue or what have you.
I mean, correct me if I’m wrong but that never works for me.
I don’t check >Is Kinematic, and I am sure that they’re on the same plane, so they definitely interact (as evidenced also by the jittering and stuff).
TL;DR:
I just want a good movement script for 2D, but all the stuff I find has errors involving sticking to colliders, going through them, or using too many different aspects for me to easily learn from the scripts so I can make my own. I would like some tips to maybe point out what is going on, and where I can start learning these (apparently) finer skills. Or just point out how silly I am if I’m just being an accidental idiot, haha.
Further TL;DR:
Help me, the movement scripts are mean and borked for me ![]()