# Destroy Object

**URL:** <https://forums.unrealengine.com/t/destroy-object/830128>\
**Category:** Blueprint\
**Tags:** command, unreal-engine, Blueprint\
**Created:** [March 28, 2023, 2:54pm UTC](https://forums.unrealengine.com/t/destroy-object/830128 "2023-03-28T14:54:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kyle\_ren4](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/kyle_ren4/32/586502_2.png) [@kyle\_ren4](https://forums.unrealengine.com/u/kyle_ren4)\
**Post date:** [March 28, 2023, 2:54pm UTC](https://forums.unrealengine.com/t/destroy-object/830128/1 "2023-03-28T14:54:13Z")

</div>

I’m making a player command for a top down game that spawns an object in front of the player I’m experiencing two problems with it:

1. I want the object to be destroyed after 3 seconds or after releasing the command key. When I wait and the object gets destroyed an error pops up after exiting the game.
2. I’m trying to get the object to follow me as I move around does anyone have any ideas

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [March 28, 2023, 3:04pm UTC](https://forums.unrealengine.com/t/destroy-object/830128/2 "2023-03-28T15:04:41Z")

</div>

Try this:

- in the actor being spawned:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/6/a/c6ab28623fdf8b7d5616b9699c9449dfed620de8.png)

- in the player:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/2/f/a2f416c750e59bbc4da74bd18f8d132fa4c4c45b.jpeg)

- you can promote return values to variables like so:

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/1/6/8169f98cb06652edfb502201d4512f88b574d0d6.png)

- and right clicking actor get nodes can convert them to their validated variants:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/0/8/20861db1b68c44329d5cd35e192b2f10cab278ca.png)

---

<div class="post-metadata">

**Author:** ![kyle\_ren4](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/kyle_ren4/32/586502_2.png) [@kyle\_ren4](https://forums.unrealengine.com/u/kyle_ren4)\
**Post date:** [March 28, 2023, 3:37pm UTC](https://forums.unrealengine.com/t/destroy-object/830128/3 "2023-03-28T15:37:44Z")

</div>

What are the function names for set spawned object and get is Valid from cause I can’t find them?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [March 28, 2023, 3:46pm UTC](https://forums.unrealengine.com/t/destroy-object/830128/4 "2023-03-28T15:46:44Z")

</div>

The last 2 screenshots explain it. Right click the pins / nodes. It’s a variable that you can name yourself - I named it SpawnedObject.

Consider naming it in a more meaningful fashion, like `aProtectionShield` or `aAttackDrone`, whatever it’s supposed to do.

---

<div class="post-metadata">

**Author:** ![kyle\_ren4](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/kyle_ren4/32/586502_2.png) [@kyle\_ren4](https://forums.unrealengine.com/u/kyle_ren4)\
**Post date:** [March 29, 2023, 2:42pm UTC](https://forums.unrealengine.com/t/destroy-object/830128/5 "2023-03-29T14:42:48Z")

</div>

I tried your suggestion for destroying an actor but it doesn’t work the spawned object still stays there until the end of the object’s lifespan it’s possible that we’re using different versions of unreal. Mines 5.0.3 for reference.

---

<div class="post-metadata">

**Author:** ![kyle\_ren4](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/kyle_ren4/32/586502_2.png) [@kyle\_ren4](https://forums.unrealengine.com/u/kyle_ren4)\
**Post date:** [March 29, 2023, 2:53pm UTC](https://forums.unrealengine.com/t/destroy-object/830128/6 "2023-03-29T14:53:01Z")

</div>

Nevermind you were right
