# How to know when an actor is not rendered? \[Partially-solved\]

**URL:** <https://forums.unrealengine.com/t/how-to-know-when-an-actor-is-not-rendered-partially-solved/2223250>\
**Category:** Debugging, Optimization, & Profiling\
**Tags:** unreal-engine, question, CPP\
**Created:** [December 15, 2024, 7:15pm UTC](https://forums.unrealengine.com/t/how-to-know-when-an-actor-is-not-rendered-partially-solved/2223250 "2024-12-15T19:15:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [December 15, 2024, 7:15pm UTC](https://forums.unrealengine.com/t/how-to-know-when-an-actor-is-not-rendered-partially-solved/2223250/1 "2024-12-15T19:15:45Z")

</div>

I have a couple of actors with custom movement.  
Movement is controlled from the tick event.

```auto
void AMyActor::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
   //Custom movement code here
}

```

I would like to disable the tick event if no player is watching (the actor is not rendered).  
Because it consumes CPU time an it is a waste.

Does anyone know how to do it?

Thank you very much!!

* * *

The problem is Partially-solved (read my last post).  
Just a couple of details are missing to be complete.

* * *

> [@How to know when an actor is not rendered? \[Partially-solved\]](https://forums.unrealengine.com/t/how-to-know-when-an-actor-is-not-rendered-partially-solved/2223250/10):
>
> I copied some lines of code from UMovementComponent From a function called. ShouldSkipUpdate(float DeltaTime) It seems to work. bool AMyActor::ShouldSkipUpdate(float DeltaTime) const { if (!IsValid(StaticMesh)) { return true; } if (IsNetMode(NM\_DedicatedServer)) { // Dedicated servers never render return true; } if (StaticMesh-\>Mobility != EComponentMobility::Movable) { return true; } const float RenderTimeThreshold = 0.41f; UWorld\* TheWorld = GetWorld(); if (TheWorl…

---

<div class="post-metadata">

**Author:** ![Jinkel](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jinkel/32/998041_2.png) [@Jinkel](https://forums.unrealengine.com/u/Jinkel)\
**Post date:** [December 15, 2024, 7:40pm UTC](https://forums.unrealengine.com/t/how-to-know-when-an-actor-is-not-rendered-partially-solved/2223250/2 "2024-12-15T19:40:32Z")

</div>

I think you have to use the dot product.

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [December 15, 2024, 7:49pm UTC](https://forums.unrealengine.com/t/how-to-know-when-an-actor-is-not-rendered-partially-solved/2223250/3 "2024-12-15T19:49:46Z")

</div>

Sorry, maybe I explained it wrong… the idea is that it only moves when it is rendered. (It only renders when some player looks at it).

USkeletalMesh has a similar option:

```auto

	VisibilityBasedAnimTickOption = EVisibilityBasedAnimTickOption::OnlyTickPoseWhenRendered;

```

But in my specific case I am using a static mesh that has not bones.

Thank you very much for your response!!

---

<div class="post-metadata">

**Author:** ![Jinkel](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jinkel/32/998041_2.png) [@Jinkel](https://forums.unrealengine.com/u/Jinkel)\
**Post date:** [December 15, 2024, 7:54pm UTC](https://forums.unrealengine.com/t/how-to-know-when-an-actor-is-not-rendered-partially-solved/2223250/4 "2024-12-15T19:54:56Z")

</div>

Well, the default dynamic occlusion occludes everything that is not rendered, if it were a skeletal mesh, the same but if you want to occlude animations there is an option for that.

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [December 15, 2024, 8:03pm UTC](https://forums.unrealengine.com/t/how-to-know-when-an-actor-is-not-rendered-partially-solved/2223250/5 "2024-12-15T20:03:40Z")

</div>

The problem is that the movement still works even if the actor is not visible (Even if occluded).  
It has not animations…

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [December 15, 2024, 8:09pm UTC](https://forums.unrealengine.com/t/how-to-know-when-an-actor-is-not-rendered-partially-solved/2223250/7 "2024-12-15T20:09:45Z")

</div>

> [@Jinkel](#):
>
> OnRenderer

This sounds better…  
I’ll look into it.  
Thanks!!

---

<div class="post-metadata">

**Author:** ![Jinkel](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jinkel/32/998041_2.png) [@Jinkel](https://forums.unrealengine.com/u/Jinkel)\
**Post date:** [December 15, 2024, 8:19pm UTC](https://forums.unrealengine.com/t/how-to-know-when-an-actor-is-not-rendered-partially-solved/2223250/8 "2024-12-15T20:19:28Z")

</div>

ok im wrong, this is in blueprint:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/9/e/49e52660e380ea3a661c264ee48f5bcbdc0e2f8a.png)

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [December 15, 2024, 8:21pm UTC](https://forums.unrealengine.com/t/how-to-know-when-an-actor-is-not-rendered-partially-solved/2223250/9 "2024-12-15T20:21:41Z")

</div>

I will try it…  
thanks a lot!!

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [December 15, 2024, 9:26pm UTC](https://forums.unrealengine.com/t/how-to-know-when-an-actor-is-not-rendered-partially-solved/2223250/10 "2024-12-15T21:26:17Z")

</div>

I copied some lines of code from UMovementComponent  
From a function called.

`ShouldSkipUpdate(float DeltaTime)`

It seems to work.

```auto
bool AMyActor::ShouldSkipUpdate(float DeltaTime) const
{
	if (!IsValid(StaticMesh))
	{
		return true;
	}
	
	if (IsNetMode(NM_DedicatedServer))
	{
		// Dedicated servers never render
		return true;
	}
	
	if (StaticMesh->Mobility != EComponentMobility::Movable)
	{
		return true;
	}

	const float RenderTimeThreshold = 0.41f;
	UWorld* TheWorld = GetWorld();
	if (TheWorld->TimeSince(StaticMesh->GetLastRenderTime()) <= RenderTimeThreshold)
	{
		return false; // Rendered, don't skip it.
	}
	return true;
}

```

This is definitely a problem with replication of the movement because it is an actor that applies damage.

If it does not move on the dedicated server the client and server will have different positions

So the problem now is. If it doesn’t render on the client, it must not move on the server…

Another problem is that the Tick function is not disabled (it just doesn’t move when not rendering). So this is consuming CPU time anyway and the ideally is disable it completely.

Help with this is welcome!!
