Isometric Character Controller in Unity

Isometric movement may seem easy at first, until you realize your character does not move according to your input... I show you how to skew your navigation input to allocate for the rotation of the camera.
DISCLAIMER: I missed a few things in the video which are corrected in the script below.
Script: bit.ly/3BeDwB7
Isometric camera setup: • Isometric Camera In Unity
❤️ Become a Tarobro on Patreon: / tarodev
=========
🔔 SUBSCRIBE: bit.ly/3eqG1Z6
🗨️ DISCORD: / discord
✅ MORE TUTORIALS: / tarodev
0:00 Intro
0:20 Gathering Player Input
1:05 Moving a Character
3:00 Rotating a Character
7:10 Fixing Isometric Navigation

Пікірлер: 128

  • @Tarodev
    @Tarodev2 жыл бұрын

    I have fixed a few things in this script, such as normalized diagonal movement and a few other bits and pieces. You can find it here: bit.ly/3BeDwB7

  • @themrfj

    @themrfj

    2 жыл бұрын

    I added a comment to the script about responsive input :)

  • @PunCala

    @PunCala

    2 жыл бұрын

    Correct me if I'm wrong, but if you put controls in FixedUpdate you run the risk of missing inputs as it is not called as often as Update.

  • @Tarodev

    @Tarodev

    2 жыл бұрын

    @@PunCala I gather input in Update and move in FixedUpdate :)

  • @tranvilap4713
    @tranvilap47132 жыл бұрын

    Great, simple, straightforward tutorial video as always.

  • @narkopraxis602
    @narkopraxis6022 жыл бұрын

    I love this! Another great video Taro!

  • @Tharky
    @Tharky2 жыл бұрын

    I'm binging all the good content, thanks for making such cool tutorials :)

  • @gargar_0
    @gargar_011 ай бұрын

    Thank you! This is the most intuitive tutorial I've ever seen! I love your style!

  • @Tarodev

    @Tarodev

    11 ай бұрын

    I'm glad you dig it 🙏🙏

  • @davidgarcia274
    @davidgarcia2742 жыл бұрын

    You are the best man, thanks for all the tutorials!

  • @federicopintaluba3039
    @federicopintaluba30392 жыл бұрын

    Super helpful! Thank you.

  • @ZygimantasJurevicius
    @ZygimantasJurevicius Жыл бұрын

    We need same tutorial just with Character Controller! Awesome tutorial btw!

  • @el_barracuda
    @el_barracuda2 жыл бұрын

    Although I have been working with Unity for several years now and I have been doing everything myself, thanks to the author anyway for the content! In my time, this was not the case (

  • @benfox9382
    @benfox93822 жыл бұрын

    this is a great tutorial!

  • @kdthx6043
    @kdthx60432 жыл бұрын

    Omg! It’s just what I was looking for Rn

  • @harshaljadoncs5843
    @harshaljadoncs58432 жыл бұрын

    Awesome. I like to know more about matrix to use

  • @alidemorg
    @alidemorg3 ай бұрын

    works awesome thanks!!

  • @DissolvedMotions
    @DissolvedMotions2 жыл бұрын

    Hey, can you make an tutorial about making a unity scene look nicer; lighting, materials, post processing etc. ?

  • @friedcrumpets
    @friedcrumpets2 жыл бұрын

    This is great; thank you very much :)

  • @castlecodersltd
    @castlecodersltd Жыл бұрын

    Very good, thanks for sharing

  • @petercoakes4393
    @petercoakes43932 жыл бұрын

    Thank you very much for the tutorial, it was excellent! If I wanted to add a jump mechanic to this, what would the best way to do that be?

  • @emregurses8782
    @emregurses87825 ай бұрын

    Thank you.

  • @Kapparow
    @Kapparow2 жыл бұрын

    Nice vid!

  • @ramsey2155
    @ramsey21552 жыл бұрын

    actually, the relative variable is unnecessary because if you add transform.position to something and then remove it back nothing changes because it is like: a + b = (a + b) (a + b) - b = a

  • @gunbuckybucketman4578

    @gunbuckybucketman4578

    Жыл бұрын

    Yeah, like could just use Input variable.

  • @thaihoangtruong4564
    @thaihoangtruong45642 жыл бұрын

    love it, thanks alots

  • @orifairyfire1931
    @orifairyfire19312 жыл бұрын

    I think you dropped this 👉👑

  • @Tarodev

    @Tarodev

    2 жыл бұрын

    Thank you 🙏

  • @tehuster
    @tehuster2 жыл бұрын

    You are a cool guy, you make great content, you know your shit and your funny. Subbed!

  • @osriocesar
    @osriocesar2 жыл бұрын

    You got a like and a subscriber Thank you 🙏

  • @ragerungames
    @ragerungames2 жыл бұрын

    I like the jelly shaders on your cube

  • @pdb0078
    @pdb0078 Жыл бұрын

    Really looking for the next video to learn the Camera Follow script... is it there, will it come?

  • @bars5113
    @bars51132 жыл бұрын

    Thanks a lot for these tutorials! I appreciate it. I am trying to learn hyper-casual game development and I'm building prototypes for that area. If it's possible I would like to see a tutorial for a movement logic on runner type of games (like run of life or cube surfer from voodoo). Ive tried to move the player through rigidbody.moveposition with a constant force to the +z axis and according to the inputs I move the character through x axis, however, when player slides the screen too fast to the right or left character stucks on walls since there will be a huge force on x axis (by walls I mean the mathf.clamp in horizontal axis to stay on the platform). Parenting the player and moving the parent horizontal while moving the player forward didn't workout also, when I move the parent in horizontal axis player stops moving in z because of parents' movement effect. Moreover, didn't try out the paths that have turning points that would be another problem too. Maybe a tutorial about this could be helpful for people In my opinion. Thanks a lot again!

  • @Tarodev

    @Tarodev

    2 жыл бұрын

    Good idea. I'll do a tutorial for this 😊

  • @re4727
    @re4727 Жыл бұрын

    Great vid. The one that shows the following camera was never made eventually?

  • @stylie473joker5
    @stylie473joker52 жыл бұрын

    Great video but i wish if you explained more of that matrix stuff

  • @user-qh8yj3mb1w
    @user-qh8yj3mb1w6 ай бұрын

    Thanks

  • @thegrey448
    @thegrey4482 жыл бұрын

    really nice for this one. could you create animation tutorial for flying such as butterfly for 3d like rotate and flying smoothly. thanks in advance. mate.

  • @alexandres.vasconcelos8017
    @alexandres.vasconcelos8017 Жыл бұрын

    Hey Tarodev, did you posted the video where the camera follows the player?

  • @Darkmwar
    @Darkmwar Жыл бұрын

    Where is the video he mentioned towards the end where the camera will follow a player ? Is there a video where you can move the camera in the same perspective ?

  • @Xeratas
    @Xeratas Жыл бұрын

    did you ever end up creating the "next video" you talk about in the video at the end? I didn't find it, would appreciate if you could link in case you created it :)

  • @Ocov
    @Ocov Жыл бұрын

    Great video, did you ever get round to doing the camera follow script? I can find it in your videos.

  • @charlessnix7547

    @charlessnix7547

    Жыл бұрын

    same question, it appears the answer is no?

  • @martinrohwedder6618
    @martinrohwedder66182 ай бұрын

    Hello. Can you make a video on how to rotate the camera in a smooth 90 degree rotation on the y axis around the targeted player object on a key press please. Your videos are very informative and good.

  • @Snakebloke
    @Snakebloke Жыл бұрын

    Absolute legend! Thank you so much for your help in this, I've been a Python dev for a few years, but for some reason, this C# and Unity isn't clicking...

  • @Tarodev

    @Tarodev

    Жыл бұрын

    You'll get it brother. I bet it'll happen all of a sudden too, as you've been doing python.

  • @datablob
    @datablob2 жыл бұрын

    isotastic 👌

  • @Tarodev

    @Tarodev

    2 жыл бұрын

    Oh blobby

  • @diligencehumility6971
    @diligencehumility69712 жыл бұрын

    Very cool. I'd like to make an isometric game like this, but would like to make the assets in 2D/pixelart. How would you fit 2D pixelart into a 3D world like this, and still have it pixel perfect?

  • @aaryag5683

    @aaryag5683

    Жыл бұрын

    you could either have 3d assets and have a pixel perfect shader or you could have 2d materials for the 3d objects

  • @ABEHrEP
    @ABEHrEP2 жыл бұрын

    Great tutorial, simple and straight to the point! One small thing tho, in your updated script that you've linked in the description you use "_input.normalized.magnitude" in Move function, but it doesn't seem to be working properly for me (Unity 2020.3.20f1), it stops being responsive to how hard you're pushing the stick, while the approach mentioned in the video "_input.magnitude" works properly.

  • @nickgutschow4504

    @nickgutschow4504

    Жыл бұрын

    I know this is necro, but for other late readers in case it might be useful, this comment makes sense because normalized returns the directional component of a vector, i.e. the vector pointing in the same direction as the raw vector but with a length of 1, and .magnitude returns the length of the vector, but in this case .magnitude is being called on the already normalized version of the raw so would always return the scalar 1 because it is a referencing a unit vector, regardless of controller deflection. Agreed, nice tight tutorial.

  • @benfox9382
    @benfox93822 жыл бұрын

    Bit of a tangent Q - your renders, in both scene and game tab, look infinitely better than the bog standard ones my unity has on new project (I am new to unity as of yesterday). Do I need to tweak settings to get this higher quality that I see in yours? Talking particularly about the shadows and reflections on the gold cube. Thanks!

  • @Tarodev

    @Tarodev

    2 жыл бұрын

    Look into reflection probes and metallic materials. That'll get you some of the way there. Look into lighting, post processing, ambient effects (dust for example). Finally look into shaders.

  • @benfox9382

    @benfox9382

    2 жыл бұрын

    @@Tarodev Amazing, thank you! Have just completed a sandbox with lighting probes, and looking at reflection probes now. Legend! Subscribed!

  • @pkplonker
    @pkplonker Жыл бұрын

    Found this whilst looking for a ISO camera setup. Just skip all of the matrix stuff and multiply the quaternion of the camera(that has the x/y rot) by the vector to give the same outcome. Note quaternion * vector, not the other way around :)

  • @Tarodev

    @Tarodev

    Жыл бұрын

    Interesting... That's elegant

  • @FullMetalAshley
    @FullMetalAshley Жыл бұрын

    This tutorial worked almost perfectly for me! I am having a lot of issues with the player collisions though. If I bump into another object with a collider attached, my player goes crazy. It'll bounce off the other colliders, and just start flying around like crazy. It also seems to be perpetually moving? I'm not sure why, this is a default project with a standard cube set on top of a plane with another cube in front of it.

  • @user.-795

    @user.-795

    Жыл бұрын

    I have the same problem too

  • @tacitocaires5591

    @tacitocaires5591

    Жыл бұрын

    Having this problem here too. Did some research, perhaps using rb.MovePosition is doing that. Didnt figure how to fix this... maybe another line of work to the movement.

  • @louisgjohnson
    @louisgjohnson8 ай бұрын

    @Tarodev is the next video ever coming?

  • @jessek3721
    @jessek3721 Жыл бұрын

    How would I strip the rotate out of this player controller so that it only responds to the directions without the tank movement? I'm trying to make a game where the character aims at the mouse but still moves on the isometric plane.

  • @manvendradeora1382
    @manvendradeora13822 жыл бұрын

    Hi you talk about isometric camera controller video at the end is it out yet?

  • @EugeneVilder

    @EugeneVilder

    Жыл бұрын

    I'm also wondering if it's out yet.

  • @HansPeter-gx9ew
    @HansPeter-gx9ew5 ай бұрын

    nice beginner video but I would wish more for taking the camera forward and up and project it into the main plane

  • @alaslipknot
    @alaslipknot2 жыл бұрын

    that (0,45,0) Vector3 is the camera rotation right ? does it mean that replacing that with any Camera rotation will give the correct result ? also does it work with Perspective cameras ?

  • @Tarodev

    @Tarodev

    2 жыл бұрын

    Yes that's exactly what it means! Very flexible. Try it and see 😊 And yes, it does work with a perspective camera!

  • @mikeonthebox
    @mikeonthebox Жыл бұрын

    I'm guessing it's because I'm not super familiar with C# but was wondering how _input knew the method .ToIso was available to it, when we never reference Helpers in that file.

  • @andrewkapaldo5775
    @andrewkapaldo577511 ай бұрын

    Is this using the new player input system or using the old one?

  • @ryancollins4243
    @ryancollins42432 жыл бұрын

    I highly recommend using something like Nvidia Broadcast, especially when using a mechanical keyboard, for reducing noise in the audio recording.

  • @Tarodev

    @Tarodev

    2 жыл бұрын

    Do you know if Nvidia Broadcast cuts off the beginning/end of some sentences? I've found that a problem using some OBS filters. This is my fault as I ordered a loud keyboard for some reason -.-

  • @ryancollins4243

    @ryancollins4243

    2 жыл бұрын

    @@Tarodev I have had no issues with a problem like that. Nvidia Broadcast right now is actually more so just a virtual audio interface, so it would be able to just feed right into whatever OBS you already use.

  • @Tarodev

    @Tarodev

    2 жыл бұрын

    @@ryancollins4243 that's awesome. I'm going to download it right now

  • @EnterpriseKnight

    @EnterpriseKnight

    Жыл бұрын

    @@Tarodev ooorr you could lube the keyboard and turn your tutorials into asmr goodness.

  • @Tarodev

    @Tarodev

    Жыл бұрын

    @@EnterpriseKnight That's hot

  • @Skittzy
    @Skittzy Жыл бұрын

    How would you go about creating sprites for this type of game? Isometric games are 3d but I want to use a pixel art style, or must i use a 3d model?

  • @_Irrelevant

    @_Irrelevant

    9 ай бұрын

    You can use a billboard in place of a 3d model. Have the billboard be connected to a sprite sheet, so that animations follow inputs. That's as far as I know, and I could be wrong.

  • @perdoist3627
    @perdoist36274 ай бұрын

    Nice video. But I have a question. When I tried to add mouse look pos it looks to mouse and moves toward mouse. How can I solve this problem ?

  • @mufelo
    @mufelo2 жыл бұрын

    is (transform.position + _input) - transform.position not just _input. and would you not want to instead normalize it (in general) altho not very important when using LookRotation. Not sure how the GetAxis behaves but wouldn't you also get a situation where you can move faster when your movement direction vector is something like (1,1) or is that already accounted for in GetAxisRaw?

  • @Tarodev

    @Tarodev

    2 жыл бұрын

    Hah.. You're right on both accounts. Good eye. I'll go over the code tomorrow and fix it all up before posting the script in the description.

  • @mufelo

    @mufelo

    2 жыл бұрын

    Np. Just wanted to check if I was missing something, especially since I havent worked with the axis controllers.

  • @Tarodev

    @Tarodev

    2 жыл бұрын

    @@mufelo the difference between getaxis and raw is that getaxis has some smoothing built in... So even when on a keyboard, pressing w will transition smoothly from 0-1. Using raw allows you to make your own smoothing which will be reliable across keyboard and joystick.

  • @mufelo

    @mufelo

    2 жыл бұрын

    Ahh I see, thanks!

  • @samratrajsharma726
    @samratrajsharma7262 жыл бұрын

    Can anyone help me to make the camera follow the character??

  • @sollner_fox
    @sollner_fox2 жыл бұрын

    Very cool tut, but i have one question. Why u don`t use New Input System?

  • @Tarodev

    @Tarodev

    2 жыл бұрын

    Too many people still use old input system, and until I do a video about the new input system to refer them to I will avoid it.

  • @sollner_fox

    @sollner_fox

    2 жыл бұрын

    @@Tarodev );

  • @Tarodev

    @Tarodev

    2 жыл бұрын

    @@sollner_fox (:

  • @aknkekw
    @aknkekw2 жыл бұрын

    Hey dude, thanks so much for the tutorial. I have one question and I'd appreciate if you'd answer it. Right now the character moves while rotating, how can I make it so it rotates in place and then move?

  • @saeta5733

    @saeta5733

    2 жыл бұрын

    hey, have you figured out a solution to this yet? i had the same question and have been struggling with finding an answer.

  • @aknkekw

    @aknkekw

    2 жыл бұрын

    @@saeta5733 Unfortunately not :(

  • @user-ne7ut3yx3x

    @user-ne7ut3yx3x

    Жыл бұрын

    I solved this problem. Like this transform.rotation = Quaternion.LookRotation(skewedInput, Vector3.up); //transform.rotation = Quaternion.RotateTowards(transform.rotation, rot, _rotSpeed * Time.deltaTime);

  • @aknkekw

    @aknkekw

    Жыл бұрын

    @@user-ne7ut3yx3x Thank you, if I every follow this tutorial again, I will try your solution :D

  • @shahaf1312
    @shahaf1312 Жыл бұрын

    Great tutorial. One thing that bothers me though is the fact that to the isometric nature of the scene (in 3D space), movement up and down seems slower than in the other directions.

  • @Kalahee

    @Kalahee

    Жыл бұрын

    In the case of 3D it is a perception (seems), but if you were doing 2D you would in fact ratio up and down input. Say your iso ratio is 2(h):1(v), you would halve vertical input (y axis). To push this further, imagine side-scrolling, but you were walking toward the camera. Since the camera is in orthographic (no perspective), there would be no perceptible movement toward camera at all even if your player is getting closer. Iso is a fake 3D perspective and its natural movement is in diagonal. One important detail to also note is your camera corners show further of your environment than sides or top/bottom, unless extreme ratio isometric.

  • @BIG0DEJOGANDO
    @BIG0DEJOGANDO Жыл бұрын

    I'm trying to develop an isometric roguelike, but I still don't understand how I can put character animations in this script. How was I this? Movement is simple: one animation to run, one to stand still, and a few to attack.

  • @eruditeminds4887
    @eruditeminds488710 ай бұрын

    How do you get that blue grid?

  • @gramaphenia
    @gramaphenia Жыл бұрын

    Hello, I have a question. I follow your tutorial and it works perfectly, thank you. But I have a problem. When I leave the platform I create, my character doesn't fall into the void and goes through the enemies. Will you know how I can fix that? Thanks a lot.

  • @wabschall

    @wabschall

    Жыл бұрын

    Sounds like you need to add a rigidbody component to your character,

  • @gramaphenia

    @gramaphenia

    Жыл бұрын

    @@wabschall Exactamente !!!! Muchas gracias!!! Saludos.

  • @aboziad100
    @aboziad10010 ай бұрын

    Hi can you show the vedio that shows using WASD keys and mouse please? than you

  • @d.j.5950
    @d.j.59505 ай бұрын

    error in this line (; expected) public static Vector3 ToIso (this Vector3 input) => _isoMatrix.MultiplyPoint3x4(input);

  • @TankkOneFGC
    @TankkOneFGC6 ай бұрын

    very good video. But the problem now is that if i simply construct the camera the follow the player, the isometric would be broken because it will rotating like the player. is anyone have an idea to construct the camera that will moove with the player without breaking the isometric view ?

  • @Tarodev

    @Tarodev

    6 ай бұрын

    I released a video right after this showing isometric camera 😊

  • @eXca1iburN
    @eXca1iburN2 жыл бұрын

    I'm not sure why monobehaviour was removed in the helper script, I'm not too sure what that is

  • @Tarodev

    @Tarodev

    2 жыл бұрын

    Hey there! I have a video specifically covering what MonoBehaviour is, but in short: It's a unity class which is required if you wish to attach the script to a game object in the scene. It has logic to serialize values in the editor so you can adjust them, gives you direct access to the transform component so you can move, rotate and scale your object, and a bunch of help function to manage the object. That helper script does not need to be attached to any object and is just a container to hold some code, so I removed it 😊

  • @prietinho6690
    @prietinho66902 жыл бұрын

    is he using a gamepad? because with keyboard isn't working as the video for me, thanks! And with keyboard if u press at the same time diagonal keys it speeds up

  • @Tarodev

    @Tarodev

    2 жыл бұрын

    I used both a gamepad and keyboard in this video. I've added the script in the description with fixed diagonal movement speed :)

  • @user-tu3gn6ym6v
    @user-tu3gn6ym6v6 ай бұрын

    When I move on the X-axis I feel faster than the Y-axis, is that normal and should developers change that

  • @Kalahee
    @Kalahee Жыл бұрын

    Wouldn't it be easier to simply set your scene 45 degree off if you are to move in the same plane than your input anyway?

  • @Tarodev

    @Tarodev

    Жыл бұрын

    Sounds like a nightmare for level designers. can't use grid snapping any more and you'd need to rotate every asset

  • @joelkanna3563

    @joelkanna3563

    Жыл бұрын

    @@Tarodev Yeah...

  • @d.j.5950
    @d.j.59505 ай бұрын

    please add touch movement control for mobile phone

  • @emanueltejadacoste2250
    @emanueltejadacoste22502 жыл бұрын

    Does this work for 2D?

  • @KingFourth
    @KingFourth Жыл бұрын

    A year late, I know, but ToIso refuses to work for me? Just has the red squiggly underneath.

  • @Tarodev

    @Tarodev

    Жыл бұрын

    Tolso?

  • @KingFourth

    @KingFourth

    Жыл бұрын

    @@Tarodev I figured it out. Thank you though!!!

  • @jamesxxxyz8775
    @jamesxxxyz87752 жыл бұрын

    Acceleration/declaration.

  • @lamdo7897

    @lamdo7897

    2 жыл бұрын

    smooth?

  • @yaboinachin7198
    @yaboinachin71982 жыл бұрын

    Is there any reason as to why you use vars? I think they're pretty lazy, you know the data type, use it. Dont give the processor the extra work of figuring out what it is.

  • @Tarodev

    @Tarodev

    2 жыл бұрын

    Some people like var, some people don't. Meanwhile, I'll write 'var', while you sit there writing 'Dictionary'.

  • @yaboinachin7198

    @yaboinachin7198

    2 жыл бұрын

    @@Tarodev imagine someone trying to figure out that that var is all of that? Its not intuitive at all in my opinion, but hey each to their own

  • @syedhasnadjami6008

    @syedhasnadjami6008

    2 жыл бұрын

    var vs directly typing the type has zero performance benefit. As compiler still has to check the return type of a function to check if it is assignable to the declared variable type. So it is the same performance wise. It is just a matter of preference. When I first started using unity 4-5 years ago, I always typed the data type. Now I always type var as it increased my working rate. Also, rider always suggest to use var.

  • @testpig
    @testpig Жыл бұрын

    can you update all these videos to the new unity input system?

  • @flyingroads3498
    @flyingroads34982 жыл бұрын

    Hello. I was looking for 4 directions movement up down lef right isometric view bit with mouse rotation. Can you please update the project?

  • @DevikenGames
    @DevikenGames2 жыл бұрын

    thanks sir,i just liked this video but didn't watched yet as i'm planning to start working on all your videos from the first one,hope me best luck,also i would like to know if you are thinking about making some games copies making videos like this playlist kzread.info/dash/bejne/pq1119anf8_ZlqQ.html

  • @Solo-iv8zy
    @Solo-iv8zy9 ай бұрын

    all I did is to rotate the floor by 45 degree.

  • @masoncrowe
    @masoncrowe8 ай бұрын

    private void Look() { if (canMove) { if (movement != Vector3.zero) { // Get the camera's direction without the vertical component Vector3 camForward = Camera.main.transform.forward; camForward.y = 0; camForward.Normalize(); Vector3 camRight = Camera.main.transform.right; camRight.y = 0; camRight.Normalize(); // Convert the movement vector to be relative to the camera's orientation Vector3 relativeMovement = movement.x * camRight + movement.z * camForward; transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(relativeMovement), turnSpeed); } } } private void MovePlayer() { movement = new Vector3(move.x, 0f, move.y); // Adjust movement for the camera's orientation Transform camTransform = Camera.main.transform; // Get the camera's forward and right vectors on the ground plane (y = 0) Vector3 camForward = camTransform.forward; camForward.y = 0; camForward.Normalize(); Vector3 camRight = camTransform.right; camRight.y = 0; camRight.Normalize(); // Create a camera-relative movement vector Vector3 relativeMovement = move.x * camRight + move.y * camForward; relativeMovement.Normalize(); if (canMove) { if (!isDashing) { rb.AddForce(relativeMovement * speed * 10f, ForceMode.Force); } } }

Келесі