BGE: Fix T36703: Character motion actuator local movement not working correct.
The character motion actuator local movement does not taking account of the object rotation. It is necessary to rotate the motion vector before adding the local movement. Reviewers: sybren, lordloki, moguri Reviewed By: lordloki, moguri Maniphest Tasks: T42709 Differential Revision: https://developer.blender.org/D1206
This commit is contained in:
parent
1a117ad40c
commit
29e968a315
Notes:
blender-bot
2023-02-14 11:51:44 +01:00
Referenced by issue #42709, BGE: we can't trigger multiple character motion actuator Referenced by issue #36703, Second character motion actuator overwirte forward motion [patch]
|
@ -223,6 +223,11 @@ bool KX_ObjectActuator::Update()
|
|||
else if (m_bitLocalFlag.CharacterMotion) {
|
||||
MT_Vector3 dir = m_dloc;
|
||||
|
||||
if (m_bitLocalFlag.DLoc) {
|
||||
MT_Matrix3x3 basis = parent->GetPhysicsController()->GetOrientation();
|
||||
dir = basis * dir;
|
||||
}
|
||||
|
||||
if (m_bitLocalFlag.AddOrSetCharLoc) {
|
||||
MT_Vector3 old_dir = character->GetWalkDirection();
|
||||
|
||||
|
@ -236,11 +241,6 @@ bool KX_ObjectActuator::Update()
|
|||
}
|
||||
|
||||
// We always want to set the walk direction since a walk direction of (0, 0, 0) should stop the character
|
||||
if (m_bitLocalFlag.DLoc)
|
||||
{
|
||||
MT_Matrix3x3 basis = parent->GetPhysicsController()->GetOrientation();
|
||||
dir = basis*dir;
|
||||
}
|
||||
character->SetWalkDirection(dir/parent->GetScene()->GetPhysicsEnvironment()->GetNumTimeSubSteps());
|
||||
|
||||
if (!m_bitLocalFlag.ZeroDRot)
|
||||
|
|
Loading…
Reference in New Issue