3D Player Controller in Unity. Converting my 2D Celeste Controller!
I converted my 2D Celeste controller to fit a 3D world. I had a few challenges along the way but all in all it turned out nicely. Let me know what you think!
Play the game: https://tarodev.itch.io/player-controller-3d
❤️ Become a Tarobro on Patreon: https://www.patreon.com/tarodev
🔔 SUBSCRIBE: https://bit.ly/3eqG1Z6
🗨️ DISCORD: https://discord.gg/GqeHHnhHpz
✅ MORE TUTORIALS: https://www.youtube.com/tarodev
[Music] in my last video i created a kick-ass 2d player controller inspired by celeste if you didn't watch it go do so now and then come back it worked out pretty well and feels great but my original plan was to create a 3d controller so that's what i'm doing now let's go first step was creating a simple 3d environment i'm lazy so i just scoured my 2d environment and added some orange boxes [Music] i created a new script for my 3d character and pretty much copy and pasted my 2d controller script inside the major difference between a 2d and 3d controller is that we don't use joystick input for the x and y axis but instead the x and z axis we still use the vertical input from controllers so i simply rename my y to z i commented or removed any 2d specific code from my script such as which direction the player is facing then just decided it'd be cleaner handling each state as i get to it so i deleted basically everything to just focus on the walking i replaced the 2d wall code to use the z-axis i removed all acceleration for now and just used the raw input for the look direction it was as easy as setting my model's transform forward equal to my walk direction i added a check to ensure if there was no input that frame i wouldn't set my look direction this stopped it from snapping back to its default direction when i let go of the key alright first test not bad not bad i hooked up my camera to follow the player feels pretty good so far but it's very snappy and doesn't have the celeste acceleration and de-acceleration we all love so i quickly added in a basic system to handle it you can see it clearly when using extreme values my 2d jump script worked great without any additional changes the only thing i had to change for the dash was to execute it on the x z plane instead of the x y plane now one downside to doing this in 3d is there is no easy way to give the directional freedom you have in the 2d controller in 2d your vertical input can be used to direct the dash but in 3d you're using the vertical input for character move direction i'd do something to alleviate the shortcoming a bit later in the video the wall climbing took a little bit of fiddling from the 2d variant first i had to change my wall detection from static left and right to wherever my model was facing then i had to assign my z input to the character's y axis while grabbing to allow movement this looked ridiculous so i prevented rotation while wall sliding or grabbing and ensured they were perfectly facing the wall by shooting a ray forwards on the frame we begin to hold the grab to get the walls normal direction then set my look direction to the inverse next i wanted to fix how far from the wall the character would sometimes be when grabbing i did this by checking if i was more than .5 units from the wall and if so move in closer pretty simple stuff i wanted a way to give more freedom to the dash directions i was playing with a few ideas but a member of my discord suggested i add dash targets if one is in range when you press dash it'll set your direction towards the target and dash until it hits its mark i do this by casting a capsule forward and then choosing the closest one detected let's try this out okay that's cool but not what we want well that works pretty good it's a little bit clumsy but with some work it could turn out nicely another day maybe alright so that's all the state's converted to 3d and it feels pretty responsive for a real test i popped over the blender to make some tentacles then i constructed this weird tentacle monster to chase me around the map shooting at me by the way if you're enjoying this video leave a like and let me know in the comments below what you'd like to see next anyway let's see how this looks all put together [Music] i wouldn't say the controller is anywhere close to perfect but it's about as far as i want to take it at this stage if you want to look through the code or play this little level i made here i left them both in the description if you enjoyed this quick little video consider subscribing to see what i get up to next tara dev signing out you