Bug Report
milford-sandler-0103 opened this issue · comments
Describe the bug | Bug描述
A clear and concise description of what the bug is.
void MotorComponent::calculateTargetPosition(const Vector3&& current_position)
{
Vector3 final_position;
switch (m_controller_type)
{
case ControllerType::none:
final_position = current_position + m_desired_displacement;
break;
case ControllerType::physics:
final_position = m_controller->move(current_position, m_desired_displacement);
break;
default:
final_position = current_position;
break;
}
// Piccolo-hack: motor level simulating jump, character always above z-plane
if (m_jump_state == JumpState::falling && final_position.z + m_desired_displacement.z <= 0.f)
{
final_position.z = 0.f;
m_jump_state = JumpState::idle;
}
m_is_moving = (final_position - current_position).squaredLength() > 0.f;
m_target_position = final_position;
}
此处position.z <= 0来判断角色是否已经落地,所以跳到别的物体上时,角色的状态一直是JumpState::falling,之后就无法再次跳跃了
Steps to reproduce | 如何复现
Steps to reproduce the behavior:
- 跳到场景中的立方体上
- 再次按空格键,无法起跳
有没有其他更好的办法判断玩家落地(或者落到其他物体上)?