Hello, i'm making an isometric game :)
On keyboard everything work fine, like when pressing W the player will move top right.
Problem is that, when i connect a controller, putting joystick up will move player top right. But that feel weird and i want player to move exactly like joystick orientation.
So, i want to know if there is a way to correct that easily or if i have to modify the code to check for keyboard or controller.
#Isometric controls
1 messages · Page 1 of 1 (latest)
You'd have to share your code and how you set up your input handling
there's no magic here that is making that work as expected
it's likely code you wrote doing it
my bad, it's the unity third person asset
Basically all the relevant stuff will be coming from the PlayerInput.cs script
not this one
Basicly player move forward using keyboard but when using the xbox controller, the control is different cause my camera is isometric and isn't behind player
Or sorry
rather the StarterAssetsInputs.cs script
ok there's nothing really in here - so it will then be coming from how the input actions asset is configured
Also i use this to place camera at isometric position from player
the problem is from the fact that camera is rotated compared to player
Isn't the camera rotated the same no matter which input device you're using though?
Your explanation doesn't make sense to me.
yes but on keyobard W makes player move diagonal. But it feel weird when you put your joystick up that plyer move diagonal top right
Sounds like its working completely normally
but you actually want it to behave differently?
i mean when you play isometric game on controller shouldn't placing joystick up makes character go up ?
IDK, that's up to you as the game designer
if that's what you want then yes you'll need to add some special handling for it
oki :)
i'll add that
I would make a different input action for the joystick, unbind it from the nroaml move action, and add a separate handling path for that that rotates the vector 45 degrees before feeding into the movement script
i guess i just need to add roation based on camera position cause i'm not even sure it's 45 degrees. bruh
Either that or you need to write a custom processor that rotates the vector and use that for your joystick binding
great, i'll do that :O
{
Vector3 dir = transform.forward * inputManager.verticalInput;
dir += transform.right * inputManager.horizontalInput;
dir.y = 0;
dir.Normalize();
return dir;
}
``` this is how i handle my isometric movement
and rotation with
PlayerControls playerControls;
InputManager inputManager;
PlayerLocomotion locomotion;
public Camera cam;
[Header("Rotation Settings")]
public float smoothTime = 0.07f;
public float rotationSpeed = 400f;
private Vector3 currentEuler;
private Vector3 velocity;
void OnEnable()
{
if (playerControls == null)
playerControls = new PlayerControls();
inputManager = GetComponent<InputManager>();
locomotion = GetComponent<PlayerLocomotion>();
playerControls.Enable();
}
void OnDisable() => playerControls.Disable();
void Start()
{
if (cam == null)
cam = Camera.main;
currentEuler = transform.eulerAngles;
}
{
Vector2 screenPos = playerControls.PlayerMovement.Look.ReadValue<Vector2>();
if (screenPos.sqrMagnitude < 0.01f)
return;
// Project screen → world at player's height (no raycasting)
Vector3 mouseWorld = ProjectToPlayerHeight(screenPos);
Vector3 dir = mouseWorld - transform.position;
dir.y = 0f;
if (dir.sqrMagnitude < 0.0001f)
return;
float angle = Mathf.Atan2(dir.x, dir.z) * Mathf.Rad2Deg;
float newY = Mathf.SmoothDampAngle(
currentEuler.y,
angle,
ref velocity.y,
smoothTime,
rotationSpeed
);
currentEuler.y = newY;
transform.eulerAngles = currentEuler;
}
// ------------------------------------------------------------
// :earth_americas: World Projection (NO RAYCASTS)
// This projects the mouse onto the player's height
// using pure camera projection math.
// ------------------------------------------------------------
Vector3 ProjectToPlayerHeight(Vector2 screenPos)
{
// Convert screen position to a 3D point on the camera plane
Vector3 near = new Vector3(screenPos.x, screenPos.y, cam.nearClipPlane);
Vector3 far = new Vector3(screenPos.x, screenPos.y, cam.farClipPlane);
Vector3 p0 = cam.ScreenToWorldPoint(near);
Vector3 p1 = cam.ScreenToWorldPoint(far);
// Direction of projection
Vector3 v = p1 - p0;
// Solve for intersection with horizontal plane at player's Y
float t = (transform.position.y - p0.y) / v.y;
return p0 + v * t;
}
NOTE :: these are very basic and are a base package i made to start working on isometric games, the movement needs tweaked and isnt perfect this is just to show the logic