try to fix position of passenger

This commit is contained in:
in0finite 2019-07-14 02:20:30 +02:00
parent 2a56f7f336
commit bec4139a68
2 changed files with 19 additions and 7 deletions

View file

@ -10,6 +10,7 @@ namespace SanAndreasUnity.Behaviours.Peds.States
public class VehicleSittingState : BaseVehicleState
{
Vector3 m_vehicleParentOffset = Vector3.zero;
Vector3 m_rootFramePos = Vector3.zero;
@ -68,7 +69,14 @@ namespace SanAndreasUnity.Behaviours.Peds.States
BaseVehicleState.PreparePedForVehicle(m_ped, vehicle, seat);
//this.UpdateAnimsWhilePassenger();
// save root frame position
this.UpdateWheelTurning(); // play driver anim
m_model.AnimComponent.Sample(); // sample it
if (m_model.RootFrame != null)
m_rootFramePos = m_model.RootFrame.transform.localPosition; // save root frame position
this.UpdateAnimsInternal(); // restore the correct anim
m_model.AnimComponent.Sample();
}
@ -91,6 +99,12 @@ namespace SanAndreasUnity.Behaviours.Peds.States
if (!this.IsActiveState)
return;
this.UpdateAnimsInternal();
}
void UpdateAnimsInternal()
{
var seat = this.CurrentVehicleSeat;
if (seat != null)
{
@ -99,7 +113,6 @@ namespace SanAndreasUnity.Behaviours.Peds.States
else
this.UpdateAnimsWhilePassenger();
}
}
protected virtual void UpdateWheelTurning()
@ -127,6 +140,9 @@ namespace SanAndreasUnity.Behaviours.Peds.States
{
// we have to assign offset every frame, because it can be changed when ped model changes
m_model.VehicleParentOffset = m_vehicleParentOffset;
// same goes for root frame position
if (m_model.RootFrame != null)
m_model.RootFrame.transform.localPosition = m_rootFramePos;
m_model.PlayAnim(AnimGroup.Car, AnimIndex.SitPassenger, PlayMode.StopAll);
}

View file

@ -20,15 +20,11 @@
- Does 'O' button changes quality level ?
- **don't load textures on headless server ;**
- **When model is changed for a passenger, his position is moved to start of anim** ;
- **Are weapon audio clips unloaded ? - no ; memory is increased by 90 KB for 5 weapons (when ped is spawned) ;**
- When ped changes model, animation clips increase memory usage by 0.8 MB
- Map window: **don't draw vehicles** ;
- **When ped changes model, animation clips increase memory usage by 0.8 MB**
- Play sounds: horn ; empty weapon slot ; ped damage ; footsteps in run and sprint states ;