// Update is called once per frame /* protected override void UpdateMyBehavior() * { * if (mIsMoveingTowardsPlayer == true) * { * MoveTowardsPlayer(); * } * UpdateAnimations(); * }*/ private void MoveTowardsPlayer() { float distance = mTargetTransform.position.x - mTransform.position.x; DIRECTION direction; if (distance == 0) { return; } if (distance < 0) { distance *= -1; direction = DIRECTION.LEFT; } else { direction = DIRECTION.RIGHT; } if (distance < mMaxDistance && distance > mMinDistance) { mIsInMeleRange = false; b_PhysicsBehavior.SetMoving(direction, mMaxSpeed); } else if (distance > mMaxDistance) { mIsInMeleRange = false; //idle movement } else { mIsInMeleRange = true; b_PhysicsBehavior.SetMoving(0, 0); } if (direction == DIRECTION.LEFT) { mFacingDirection = DIRECTION.LEFT; } else if (direction == DIRECTION.RIGHT) { mFacingDirection = DIRECTION.RIGHT; } }
private void Move() { float direction = mTargetTrasform.position.x - transform.position.x; if (direction < mMaxDistance) { b_PhysicsBehavior.SetMoving(direction, mMaxSpeed); } }
void Move() { float inputValue; inputValue = Input.GetAxis(mInput.joystickHorizontal); if (mIsTargeting == false && inputValue != 0) { mCanMove = true; } else { mCanMove = false; } if (mCanMove == true) { float speed; if (b_PhysicsBehavior.GetIsGrounded() == true) { speed = mNormalSpeed; } else { speed = mAirSpeed; } if (inputValue > 0) { b_PhysicsBehavior.SetMoving(DIRECTION.RIGHT, speed); } else { b_PhysicsBehavior.SetMoving(DIRECTION.LEFT, speed); } } else { b_PhysicsBehavior.SetMoving(DIRECTION.DEFAULT, 0); } }