Jump to content
  • Advertisement
Sign in to follow this  

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.

If you intended to correct an error in the post then please contact us.

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);

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

tVector3 transformedDirection(baseDirection.y, 0, baseDirection.x);
float angle = MathTools::getAngleBetweenVectors(baseCameraLookAt,
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]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!