I am following this tutorial on 2.5d perspective:

The author mentions and demonstrates that the movement is not in sync when the orthogonal camera is in 45 degrees.

When I press the up arrow I want to move 1/2 speed in the x axis and half speed in the z axis. I'm having difficulty fighting an elegant way to achieve this.

It works somewhat if in the velocity calculation section of the code in the video I do:

	if direction_ground.x != 0:
		velocity = Vector3(
			direction_ground.x * speed/2 + direction_ground.y * speed/2,
			velocity_y,
			direction_ground.y * speed/2 + direction_ground.x * speed/2)
	elif direction_ground.y != 0:
		velocity = Vector3(
			direction_ground.x * speed/2 - direction_ground.y * speed/2,
			velocity_y,
			direction_ground.y * speed/2 - direction_ground.x * speed/2)

The above makes sideways movement work correctly. Diagonal unhandled still

But, I'd prefer to not use this inelegant system with if's.

He did the isometric perspective using the 3D engine with a orphographic camera. If you did the same thing, you should be able to just have the character move along the X and Z axis and it will look correct in the game.

The above code moves the character half along the x axis and half along the z axis when pressing down/up/left/right.

I'm just wondering if there is a more elegant, less processor intensive way of doing it. I feel like doing ifs every physics step is a bad idea. There any way to make it make the character see the world as rotated so that it sees y-axis as half x and half z?

Here is the full code with mutliple ifs, now with diagonal movement working as. The movement does work how I want it to work, but I feel like there must be a better way without using so many ifs'

	if (direction_ground.x > 0 and direction_ground.y > 0) or (direction_ground.x < 0 and direction_ground.y < 0):
		velocity = Vector3(
			direction_ground.x *speed/2 - direction_ground.y * speed/2,
			velocity_y,
			direction_ground.y *speed/2 + direction_ground.x * speed/2)
	elif (direction_ground.x > 0 and direction_ground.y < 0) or (direction_ground.x < 0 and direction_ground.y > 0):
		velocity = Vector3(
			direction_ground.x *speed/2 - direction_ground.y * speed/2,
			velocity_y,
			-direction_ground.y *speed/2 - direction_ground.x * speed/2)
	else:
		if direction_ground.x != 0:
			velocity = Vector3(
				direction_ground.x * speed/2 + direction_ground.y * speed/2,
				velocity_y,
				direction_ground.y * speed/2 + direction_ground.x * speed/2)
		elif direction_ground.y != 0:
			velocity = Vector3(
				direction_ground.x * speed/2 - direction_ground.y * speed/2,
				velocity_y,
				direction_ground.y * speed/2 - direction_ground.x * speed/2)
3 years later