// Called when the game starts or when spawned void ASyncedMapPhysicsEntity::BeginPlay() { Super::BeginPlay(); if (Role != ROLE_Authority) { DisableComponentsSimulatePhysics(); } }
// Sets default values AZanshinBasicArrow::AZanshinBasicArrow() : Super() { Root = CreateDefaultSubobject<USceneComponent>(TEXT("RootComponent")); // Use a ProjectileMovementComponent to govern this projectile's movement ProjectileMovement = CreateDefaultSubobject<UProjectileMovementComponent>(TEXT("ProjectileComponent")); ProjectileMovement->UpdatedComponent = Root; ProjectileMovement->InitialSpeed = 0.0f; ProjectileMovement->MaxSpeed = 6000.f; ProjectileMovement->bRotationFollowsVelocity = true; ProjectileMovement->bAutoActivate = false; ProjectileMovement->bShouldBounce = false; ProjectileMovement->bEditableWhenInherited = true; ProjectileMovement->SetNetAddressable(); ProjectileMovement->SetIsReplicated(true); // Use a sphere as a simple collision representation TipSphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("SphereComp")); TipSphereComponent->InitSphereRadius(2.5f); TipSphereComponent->BodyInstance.SetCollisionProfileName("Projectile"); TipSphereComponent->OnComponentHit.AddDynamic(this, &AZanshinBasicArrow::OnHit); // set up a notification for when this component hits something blocking TipSphereComponent->SetNetAddressable(); TipSphereComponent->SetIsReplicated(true); // Players can't walk on it TipSphereComponent->SetWalkableSlopeOverride(FWalkableSlopeOverride(WalkableSlope_Unwalkable, 0.f)); TipSphereComponent->CanCharacterStepUpOn = ECB_No; AnimationArrow = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("AnimationArrow")); AnimationArrow->AttachTo(TipSphereComponent); FlyingArrow = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("FlyingArrow")); FlyingArrow->AttachTo(TipSphereComponent); ArrowAudioComponent = CreateDefaultSubobject<UAudioComponent>(TEXT("SoundComp")); ArrowAudioComponent->Sound = ArrowSound; ArrowAudioComponent->AttachTo(TipSphereComponent); // Set as root component RootComponent = TipSphereComponent; RootComponent->SetNetAddressable(); RootComponent->SetIsReplicated(true); DisableComponentsSimulatePhysics(); bSpecialArrow = false; KillTypeArrow = ArrowKillType::STANDARD; PrimaryActorTick.bCanEverTick = true; }
void APawn::TurnOff() { if (Role == ROLE_Authority) { SetReplicates(true); } // do not block anything, just ignore SetActorEnableCollision(false); UPawnMovementComponent* MovementComponent = GetMovementComponent(); if (MovementComponent) { MovementComponent->StopMovementImmediately(); MovementComponent->SetComponentTickEnabled(false); } DisableComponentsSimulatePhysics(); }