Choppy Diagonal Movement

Hey guys/gals! New to these parts and I have ran into an issue, I did some poking around and took care of the issue with Diagonal movement speed, but mine seems to be choppy, so I’m unsure if it’s my code or just how Unity updates, let me know if I made some newbie mistake here… (This is something I’m doing to learn)

Below is a small video of the scene window, I started the video at the point where I started diagonal movement to show that its clunky looking, but before that I showed that the other movements are not like that…
Video of the Clunky Movement

In game the camera is top down so its extremely noticeable, I’ve also have attempted to change and split up the moveDirection Vector3 just in case it was causing it but that was unsuccessful or my ‘newbieness’ didn’t get it correct…

Anyways, here’s the movement code that I’m working with, not the whole script, but if you need it I have no issues posting it, any help would be appreciated.

// Only allow movement and jumps while grounded
		if(grounded) {
			
			if(allowAutoWalk){
				//pushbuffer to avoid on/off flipping
				if(pbuffer>0){
					pbuffer -=Time.deltaTime;
				}
				
				if(pbuffer<0){
					pbuffer=0;
				}	
					
				//Automove Sidebuttonmovement
				if((Input.GetButton("Auto Walk")) && pbuffer == 0){
					pbuffer=coolDown;
					autoWalk = !autoWalk;
				}
					
		    	if(autoWalk && (yInput != 0)){
		    			autoWalk = false;			
				}
	
				if (autoWalk){
					moveDirection.z += 1;	
				}
			
			}
			//movedirection
			moveDirection = new Vector3((Input.GetMouseButton(1) ? Input.GetAxis("Horizontal")* inputModifier : 0) ,0, (Input.GetAxis("Vertical") * inputModifier));
			
			
			speedMod = walkSpeed;
			
			if(isWalking == false){
			 speedMod = runSpeed;
			}
			moveDirection = transform.TransformDirection(moveDirection) * speedMod;
			
		}
			
			UpdateStatus ();
		
		
			// Allow turning at anytime. Keep the character facing in the same direction as the Camera if the right mouse button is down.
			if(Input.GetMouseButton(1)) {
				transform.rotation = Quaternion.Euler(0,Camera.main.transform.eulerAngles.y,0);
			} 
			else{
				transform.Rotate(0,Input.GetAxis("Horizontal"), 0);
			}
			
			//Apply gravity
			moveDirection.y -= gravity * Time.deltaTime;
		
			
		
			//Get CharacterController
			controller = GetComponent<CharacterController>();
		
			//Move Charactercontroller and check if grounded
			grounded = ((controller.Move(moveDirection * Time.deltaTime)) & CollisionFlags.Below) != 0;
	}

Thanks!

-Zodiak

// Only allow movement and jumps while grounded
if(grounded) {

			if(allowAutoWalk){
				//pushbuffer to avoid on/off flipping
				if(pbuffer>0){
					pbuffer -=Time.deltaTime;
				}
				
				if(pbuffer<0){
					pbuffer=0;
				}	
					
				//Automove Sidebuttonmovement
				if((Input.GetButton("Auto Walk")) && pbuffer == 0){
					pbuffer=coolDown;
					autoWalk = !autoWalk;
				}
					
		    	if(autoWalk && (yInput != 0)){
		    			autoWalk = false;			
				}
	
				if (autoWalk){
					moveDirection.z += 1;	
				}
			
			}
			
			//movedirection
			moveDirection = new Vector3((Input.GetMouseButton(1) ? xInput * inputModifier : 0) ,0, (yInput * inputModifier - 0.001f));

			speedMod = walkSpeed;
			
			if(isWalking == false){
			 speedMod = runSpeed;
			}
			
			moveDirection = transform.TransformDirection(moveDirection) * speedMod;
			
		}

Above is the only solution I have found for this issue as of right now, It is probably sloppy as all heck, but so far haven’t seen anyone ‘chip in’ so I’ve toyed with it all night… (Note the change to the Vector3 Z section in which I added -0.001f)

Seems when movement is diagonal using something like Vector3(1,0,1) makes it clunky looking, but if you were to make it Vector3(1,0,0.9999) then it moves more fluently.

So essentially from what I can tell (again not a pro) but if in the Vector X equals Z it causes the movement to be choppy, but if there is a better solution to this, please let me know.

Thanks!
-Zodiak

Often this is because physics instructions are being run in an Update when they should be run in FixedUpdate.

void Update(){
// read and cache input here
}
void FixedUpdate(){
// move transforms here
}