I use vehicle project in ue4.21
when run the project by check run dedicate server,
go forward or back is well,but when rotate the car, it well be jitter terribly
I use vehicle project in ue4.21
when run the project by check run dedicate server,
go forward or back is well,but when rotate the car, it well be jitter terribly
I have the same issue…
i have a temp solution,
custom class physicReplication, override function OnTick and SetReplicatedTarget
ChariotPhysiscReplication.h
#include "CoreMinimal.h"
#include "PhysicsPublic.h"
#include "PhysicsReplication.h"
#include "PhysicsInterfaceUtils.h"
/**
*
*/
class CHARIOTGAME_API FChariotPhysiscReplication : public FPhysicsReplication
{
public:
FChariotPhysiscReplication(FPhysScene* PhysScene);
protected:
virtual void OnTick(float DeltaSeconds, TMap<TWeakObjectPtr<UPrimitiveComponent>, FReplicatedPhysicsTarget>& ComponentsToTargets);
virtual void SetReplicatedTarget(UPrimitiveComponent* Component, FName BoneName, const FRigidBodyState& ReplicatedTarget);
bool bUpdatePos;
};
class CHARIOTGAME_API FChariotPhysicsReplicationFactory : public IPhysicsReplicationFactory
{
public:
FChariotPhysicsReplicationFactory();
virtual FPhysicsReplication* Create(FPhysScene* OwningPhysScene) override;
virtual void Destroy(FPhysicsReplication* PhysicsReplication) override;
};
ChariotPhysiscReplication.cpp
// Fill out your copyright notice in the Description page of Project Settings.
#include "ChariotPhysiscReplication.h"
#include "PhysicsEngine/PhysicsSettings.h"
FChariotPhysiscReplication::FChariotPhysiscReplication(FPhysScene* PhysScene)
: FPhysicsReplication(PhysScene)
{
}
void FChariotPhysiscReplication::OnTick(float DeltaSeconds, TMap<TWeakObjectPtr<UPrimitiveComponent>, FReplicatedPhysicsTarget>& ComponentsToTargets)
{
if (bUpdatePos)
{
bUpdatePos = false;
FPhysicsReplication::OnTick(DeltaSeconds, ComponentsToTargets);
}
}
void FChariotPhysiscReplication::SetReplicatedTarget(UPrimitiveComponent * Component, FName BoneName, const FRigidBodyState & UpdatedState)
{
FPhysicsReplication::SetReplicatedTarget(Component, BoneName, UpdatedState);
bUpdatePos = true;
}
FChariotPhysicsReplicationFactory::FChariotPhysicsReplicationFactory()
{
}
FPhysicsReplication* FChariotPhysicsReplicationFactory::Create(FPhysScene* OwningPhysScene)
{
return new FChariotPhysiscReplication(OwningPhysScene);
}
void FChariotPhysicsReplicationFactory::Destroy(FPhysicsReplication* PhysicsReplication)
{
delete PhysicsReplication;
}
use physic in gameinstance,cpp yourself
void UChariotGameInstance::Init()
{
Super::Init();
FPhysScene::PhysicsReplicationFactory = MakeShareable(new FChariotPhysicsReplicationFactory());
}
Config DefaultEngine.ini
[/Script/Engine.PhysicsSettings]
PhysicErrorCorrection=(PingExtrapolation=0.100000,PingLimit=100.000000,ErrorPerLinearDifference=1.000000,ErrorPerAngularDifference=1.000000,MaxRestoredStateError=1.000000,MaxLinearHardSnapDistance=400.000000,PositionLerp=0.050000,AngleLerp=0.10000,LinearVelocityCoefficient=0.200000,AngularVelocityCoefficient=0.628319,ErrorAccumulationSeconds=1.000000,ErrorAccumulationDistanceSq=3.000000,ErrorAccumulationSimilarity=100.000000)
this is useful for me!
I had the same issue with an AWheeledVehicle actor smoothly replicating linear motion but snapping its rotation, especially at lower speeds. I solved the issue by increasing the Rotation Quantization Level on the actor’s Replicated Movement from Byte Components to Short Components. I’ve only tested this fix in PIE with simulated latency.