# Changing movement according to camera position in isometric scene

This topic is 3033 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey gamedev,

I am working on a side project, a isometric diablo type game. And i've run into a problem :)

I can't seem to get the movement of the player correctly mapped to the analog sticks of my controller. What i want is that when i press up on the stick, the character moves up in the world.

The movement of the character is on a XZ plane, so i figured when you point the camera straight down at the character, the stick would directly map to the correct character movement. IE up on the stick is +z and down on the stick is -z movement.

So i figured when we have the direction where the camera is looking at, and the down vector, we would calculate the angle between these vectors and transform the controller input accordingly. In code:

// Make sure our character is moving correctly, ie. when we press up we move up
tVector3 baseDirection = ControllerInputhandler::get()->getLeftStickPosition(0);
baseDirection.normalize();

tVector3 baseCameraLookAt(0, -1, 0);
tVector3 currentCameraLookAt = mCamera->getTarget() - mCamera->getPosition();
currentCameraLookAt.normalize();

tVector3 transformedDirection(baseDirection.y, 0, baseDirection.x);
float angle = MathTools::getAngleBetweenVectors(baseCameraLookAt,
currentCameraLookAt);
tMatrix matTransform = tMatrix::createAxisAngle(tVector3(0, 1, 0), angle);
transformedDirection = matTransform.transform(transformedDirection);

But i guess im missing something, since im not an expert in this kind of math! :)
I hope my question is understandable since it is quite a long story.

[Edited by - pjStyle on August 25, 2010 10:36:06 AM]

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 26
• 9
• 11
• 9
• 9
• ### Forum Statistics

• Total Topics
633714
• Total Posts
3013491
×