// Update is called once per frame void Update() { pseudo3DVelocity = (_pseudo3DPlayer.pseudo3DPosition - _lastPosition) / Time.deltaTime; _lastPosition = _pseudo3DPlayer.pseudo3DPosition; _lastDirection = direction; if (pseudo3DVelocity.y > 0) //up { if (pseudo3DVelocity.x > 0) { direction = XYDirection.XPosYPos; } else if (pseudo3DVelocity.x < 0) { direction = XYDirection.XNegYPos; } else //x == 0 { if (_lastDirection == XYDirection.XPosYNeg || _lastDirection == XYDirection.XPosYPos) { direction = XYDirection.XPosYPos; } else { direction = XYDirection.XNegYPos; } } } else if (pseudo3DVelocity.y < 0) //down { if (pseudo3DVelocity.x > 0) { direction = XYDirection.XPosYNeg; } else if (pseudo3DVelocity.x < 0) { direction = XYDirection.XNegYNeg; } else //x == 0 { if (_lastDirection == XYDirection.XPosYNeg || _lastDirection == XYDirection.XPosYPos) { direction = XYDirection.XPosYNeg; } else { direction = XYDirection.XNegYNeg; } } } else //y == 0 { if (pseudo3DVelocity.x > 0) { //should almost always be facing front if just moving right direction = XYDirection.XPosYNeg; } else if (pseudo3DVelocity.x < 0) { direction = XYDirection.XNegYNeg; } else //x == 0 { _lastDirection = direction; } } //if (pseudo3DVelocity.x > 0 && pseudo3DVelocity.y <= 0.25) // direction = XYDirection.XPosYNeg; //else if(pseudo3DVelocity.x < 0 && pseudo3DVelocity.y <= 0.25) // direction = XYDirection.XNegYNeg; //else if (pseudo3DVelocity.x > 0 && pseudo3DVelocity.y >= 0.25) // direction = XYDirection.XPosYPos; //else if (pseudo3DVelocity.x < 0 && pseudo3DVelocity.y >= 0.25) // direction = XYDirection.XNegYPos; }
void Update() { _v3 = _directionAndMovementInterface.pseudo3DVelocity; _xyDir = _directionAndMovementInterface.direction; if (_xyDir == XYDirection.XPosYPos) { if (Math.Abs(_v3.z) > 0 + _jumpAnimationBuffer) { JumpBackRight(); } else if (Math.Abs(_v3.x) > 0 + _animationBuffer | Math.Abs(_v3.y) > 0 + _animationBuffer) { WalkBackRight(); } else { IdleBackRight(); } } else if (_xyDir == XYDirection.XPosYNeg) { if (Math.Abs(_v3.z) > 0 + _jumpAnimationBuffer) { JumpFrontRight(); } else if (Math.Abs(_v3.x) > 0 + _animationBuffer | Math.Abs(_v3.y) > 0 + _animationBuffer) { WalkFrontRight(); } else { IdleFrontRight(); } } else if (_xyDir == XYDirection.XNegYPos) { if (Math.Abs(_v3.z) > 0 + _jumpAnimationBuffer) { JumpBackLeft(); } else if (Math.Abs(_v3.x) > 0 + _animationBuffer | Math.Abs(_v3.y) > 0 + _animationBuffer) { WalkBackLeft(); } else { IdleBackLeft(); } } else //_xyDir == XYDirection.XNegYNeg { if (Math.Abs(_v3.z) > 0 + _jumpAnimationBuffer) { JumpFrontLeft(); } else if (Math.Abs(_v3.x) > 0 + _animationBuffer | Math.Abs(_v3.y) > 0 + _animationBuffer) { WalkFrontLeft(); } else { IdleFrontLeft(); } } //if (_v3.x > 0 && _v3.y > 0) // WalkFrontRight(); //else if (_v3.x < 0) // WalkFrontLeft(); //else // IdleFrontRight(); }