mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-03 20:45:33 +00:00
Merge branch 'analogue-movement' into 'master'
Analogue Joystick Movement Closes #3025 See merge request OpenMW/openmw!74
This commit is contained in:
commit
6c522a0875
4 changed files with 29 additions and 23 deletions
|
@ -518,28 +518,17 @@ namespace MWInput
|
|||
// joystick movement
|
||||
float xAxis = mInputBinder->getChannel(A_MoveLeftRight)->getValue();
|
||||
float yAxis = mInputBinder->getChannel(A_MoveForwardBackward)->getValue();
|
||||
if (xAxis < .5)
|
||||
if (xAxis != .5)
|
||||
{
|
||||
triedToMove = true;
|
||||
mPlayer->setLeftRight (-1);
|
||||
}
|
||||
else if (xAxis > .5)
|
||||
{
|
||||
triedToMove = true;
|
||||
mPlayer->setLeftRight (1);
|
||||
mPlayer->setLeftRight((xAxis - 0.5f) * 2);
|
||||
}
|
||||
|
||||
if (yAxis < .5)
|
||||
if (yAxis != .5)
|
||||
{
|
||||
triedToMove = true;
|
||||
mPlayer->setAutoMove (false);
|
||||
mPlayer->setForwardBackward (1);
|
||||
}
|
||||
else if (yAxis > .5)
|
||||
{
|
||||
triedToMove = true;
|
||||
mPlayer->setAutoMove (false);
|
||||
mPlayer->setForwardBackward (-1);
|
||||
mPlayer->setForwardBackward((yAxis - 0.5f) * 2 * -1);
|
||||
}
|
||||
else if(mPlayer->getAutoMove())
|
||||
{
|
||||
|
|
|
@ -1956,6 +1956,23 @@ void CharacterController::update(float duration, bool animationOnly)
|
|||
osg::Vec3f rot = cls.getRotationVector(mPtr);
|
||||
|
||||
speed = cls.getSpeed(mPtr);
|
||||
if(isPlayer)
|
||||
{
|
||||
// Joystick anologue movement.
|
||||
float xAxis = std::abs(cls.getMovementSettings(mPtr).mPosition[0]);
|
||||
float yAxis = std::abs(cls.getMovementSettings(mPtr).mPosition[1]);
|
||||
float analogueMovement = ((xAxis > yAxis) ? xAxis : yAxis);
|
||||
|
||||
// If Strafing, our max speed is slower so multiply by X axis instead.
|
||||
if(std::abs(vec.x()/2.0f) > std::abs(vec.y()))
|
||||
analogueMovement = xAxis;
|
||||
|
||||
// Due to the half way split between walking/running, we multiply speed by 2 while walking, unless a keyboard was used.
|
||||
if(!isrunning && !sneak && !flying && analogueMovement <= 0.5f)
|
||||
speed *= 2;
|
||||
|
||||
speed *= (analogueMovement);
|
||||
}
|
||||
|
||||
vec.x() *= speed;
|
||||
vec.y() *= speed;
|
||||
|
|
|
@ -154,16 +154,16 @@ namespace MWWorld
|
|||
if (mAutoMove)
|
||||
value = 1;
|
||||
|
||||
ptr.getClass().getMovementSettings(ptr).mPosition[1] = static_cast<float>(value);
|
||||
ptr.getClass().getMovementSettings(ptr).mPosition[1] = value;
|
||||
}
|
||||
|
||||
void Player::setLeftRight (int value)
|
||||
void Player::setLeftRight (float value)
|
||||
{
|
||||
MWWorld::Ptr ptr = getPlayer();
|
||||
ptr.getClass().getMovementSettings(ptr).mPosition[0] = static_cast<float>(value);
|
||||
ptr.getClass().getMovementSettings(ptr).mPosition[0] = value;
|
||||
}
|
||||
|
||||
void Player::setForwardBackward (int value)
|
||||
void Player::setForwardBackward (float value)
|
||||
{
|
||||
MWWorld::Ptr ptr = getPlayer();
|
||||
|
||||
|
@ -172,7 +172,7 @@ namespace MWWorld
|
|||
if (mAutoMove)
|
||||
value = 1;
|
||||
|
||||
ptr.getClass().getMovementSettings(ptr).mPosition[1] = static_cast<float>(value);
|
||||
ptr.getClass().getMovementSettings(ptr).mPosition[1] = value;
|
||||
}
|
||||
|
||||
void Player::setUpDown(int value)
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace MWWorld
|
|||
CellStore* mMarkedCell;
|
||||
|
||||
bool mAutoMove;
|
||||
int mForwardBackward;
|
||||
float mForwardBackward;
|
||||
bool mTeleported;
|
||||
|
||||
int mCurrentCrimeId; // the id assigned witnesses
|
||||
|
@ -94,9 +94,9 @@ namespace MWWorld
|
|||
bool getAutoMove() const;
|
||||
void setAutoMove (bool enable);
|
||||
|
||||
void setLeftRight (int value);
|
||||
void setLeftRight (float value);
|
||||
|
||||
void setForwardBackward (int value);
|
||||
void setForwardBackward (float value);
|
||||
void setUpDown(int value);
|
||||
|
||||
void setRunState(bool run);
|
||||
|
|
Loading…
Reference in a new issue