# Invalid actor reference passing through IsValid node

**URL:** <https://forums.unrealengine.com/t/invalid-actor-reference-passing-through-isvalid-node/472412>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [October 5, 2020, 12:32am UTC](https://forums.unrealengine.com/t/invalid-actor-reference-passing-through-isvalid-node/472412 "2020-10-05T00:32:42Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![SupraGineles](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SupraGineles](https://forums.unrealengine.com/u/SupraGineles)\
**Post date:** [October 5, 2020, 12:32am UTC](https://forums.unrealengine.com/t/invalid-actor-reference-passing-through-isvalid-node/472412/1 "2020-10-05T00:32:42Z")

</div>

i’m receiving the following error :

**Blueprint Runtime Error: “Attempted to access ZombieBP\_C\_20 via property K2Node\_ComponentBoundEvent\_Actor, but ZombieBP\_C\_20 is pending kill”. Blueprint: ZombieAIcontroller Function: Execute Ubergraph Zombie AIcontroller Graph: EventGraph Node: Branch**

And this is the branch node accesing the actor reference.

 ![317313-444.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/b/0/db07217f8f7767ed40e9c2b1b5079385dea9c254.png)

---

<div class="post-metadata">

**Author:** ![Marcis](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/marcis/32/1103070_2.png) [@Marcis](https://forums.unrealengine.com/u/Marcis)\
**Post date:** [October 5, 2020, 7:44am UTC](https://forums.unrealengine.com/t/invalid-actor-reference-passing-through-isvalid-node/472412/2 "2020-10-05T07:44:15Z")

</div>

Possibly because you’re using pure cast.

---

<div class="post-metadata">

**Author:** ![SupraGineles](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SupraGineles](https://forums.unrealengine.com/u/SupraGineles)\
**Post date:** [October 5, 2020, 11:36am UTC](https://forums.unrealengine.com/t/invalid-actor-reference-passing-through-isvalid-node/472412/3 "2020-10-05T11:36:48Z")

</div>

Hey, thanks for the reply.  
I changed to impure cast, Unfortunately i still receive the error.

---

<div class="post-metadata">

**Author:** ![Tuerer](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/tuerer/32/1008648_2.png) [@Tuerer](https://forums.unrealengine.com/u/Tuerer)\
**Post date:** [October 5, 2020, 12:04pm UTC](https://forums.unrealengine.com/t/invalid-actor-reference-passing-through-isvalid-node/472412/4 "2020-10-05T12:04:44Z")

</div>

Do you destroy the actor when setting the IsDead bool? I might be wrong, but I think since the actor is still referenced in memory until it’s cleared by the garbage collector, it’s still valid, but it’s Pending Kill, so it’s no longer accessible.

---

<div class="post-metadata">

**Author:** ![SupraGineles](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SupraGineles](https://forums.unrealengine.com/u/SupraGineles)\
**Post date:** [October 5, 2020, 12:26pm UTC](https://forums.unrealengine.com/t/invalid-actor-reference-passing-through-isvalid-node/472412/5 "2020-10-05T12:26:05Z")

</div>

Yes, the actor is getting destroyed after some time. But before destroying the actor i detach the controller.

 ![317330-aaaaaaaaaa.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/f/7/0f7b20ceb5d3033d639babdb0334c1dbce2884d9.png)

---

<div class="post-metadata">

**Author:** ![Tuerer](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/tuerer/32/1008648_2.png) [@Tuerer](https://forums.unrealengine.com/u/Tuerer)\
**Post date:** [October 5, 2020, 12:31pm UTC](https://forums.unrealengine.com/t/invalid-actor-reference-passing-through-isvalid-node/472412/6 "2020-10-05T12:31:01Z")

</div>

So you’re detaching the controller, and then you try getting controlled pawn? Maybe that’s the issue?

---

<div class="post-metadata">

**Author:** ![SupraGineles](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SupraGineles](https://forums.unrealengine.com/u/SupraGineles)\
**Post date:** [October 5, 2020, 12:36pm UTC](https://forums.unrealengine.com/t/invalid-actor-reference-passing-through-isvalid-node/472412/7 "2020-10-05T12:36:14Z")

</div>

Thats the point, if i detach the controller, why the controlled pawn reference is passing through IsValid? By the way even if i dont use the Detach node i still have the error.

---

<div class="post-metadata">

**Author:** ![Marcis](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/marcis/32/1103070_2.png) [@Marcis](https://forums.unrealengine.com/u/Marcis)\
**Post date:** [October 5, 2020, 8:29pm UTC](https://forums.unrealengine.com/t/invalid-actor-reference-passing-through-isvalid-node/472412/8 "2020-10-05T20:29:30Z")

</div>

Validate controlled pawn first, then try to cast.

---

<div class="post-metadata">

**Author:** ![SupraGineles](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SupraGineles](https://forums.unrealengine.com/u/SupraGineles)\
**Post date:** [October 6, 2020, 12:11am UTC](https://forums.unrealengine.com/t/invalid-actor-reference-passing-through-isvalid-node/472412/9 "2020-10-06T00:11:03Z")

</div>

Still the same. I tried using IsValid on all references, but the error still persist.

---

<div class="post-metadata">

**Author:** ![Tuerer](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/tuerer/32/1008648_2.png) [@Tuerer](https://forums.unrealengine.com/u/Tuerer)\
**Post date:** [October 6, 2020, 9:25am UTC](https://forums.unrealengine.com/t/invalid-actor-reference-passing-through-isvalid-node/472412/10 "2020-10-06T09:25:17Z")

</div>

I’ve checked it. After detaching from controller, Get Controlled Pawn seem to continue returning something that passed validation, but you can’t get any data from it.

Maybe you should find another way to do what you need, e.g. with death events.

---

<div class="post-metadata">

**Author:** ![SupraGineles](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SupraGineles](https://forums.unrealengine.com/u/SupraGineles)\
**Post date:** [October 6, 2020, 3:51pm UTC](https://forums.unrealengine.com/t/invalid-actor-reference-passing-through-isvalid-node/472412/11 "2020-10-06T15:51:15Z")

</div>

Ok , so before detaching and destroying the actor i destroyed the AIPerception component on controller sinse the event “On Target Perception Updated” of this component is the initial cause of the error. My idea is to prevent the component to fire the event when the actor is dead. But i dont know why, the event is still firing even after destroying the component.
