# Better way to do this instead of just casting to all objects to see wich one is the right one?

**URL:** <https://forums.unrealengine.com/t/better-way-to-do-this-instead-of-just-casting-to-all-objects-to-see-wich-one-is-the-right-one/1906124>\
**Category:** Blueprint\
**Tags:** spawn, Map, unreal-engine, spawning-actors, cast, Blueprint, question\
**Created:** [June 17, 2024, 9:28am UTC](https://forums.unrealengine.com/t/better-way-to-do-this-instead-of-just-casting-to-all-objects-to-see-wich-one-is-the-right-one/1906124 "2024-06-17T09:28:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![DonJuan1232](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DonJuan1232](https://forums.unrealengine.com/u/DonJuan1232)\
**Post date:** [June 17, 2024, 9:28am UTC](https://forums.unrealengine.com/t/better-way-to-do-this-instead-of-just-casting-to-all-objects-to-see-wich-one-is-the-right-one/1906124/1 "2024-06-17T09:28:51Z")

</div>

So when I drop an object out of my inventory I want to set the usage ammount to the new spawned object. but since I am going to have a lot of objects I want to do it a better and efficient way. Now I am just checking what object it is and then setting the values.  
My object that I spawn is made from a parent base blueprint.

I hope it makes sense what I am trying to do if not then please feel free to ask.

 ![ss](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/2/8/4283e89f80b608cb9ef483019c2307ee7912f978.png)

Thank you

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [June 17, 2024, 10:16am UTC](https://forums.unrealengine.com/t/better-way-to-do-this-instead-of-just-casting-to-all-objects-to-see-wich-one-is-the-right-one/1906124/2 "2024-06-17T10:16:03Z")

</div>

Have the actors that you cast to implement an vlueprint interface that takes in the two ints as input parameters to its function and then just call the interface function in place of the casts. If the actor iplements the interface then it is called, if not it’s ignored.

---

<div class="post-metadata">

**Author:** ![DonJuan1232](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DonJuan1232](https://forums.unrealengine.com/u/DonJuan1232)\
**Post date:** [June 17, 2024, 1:36pm UTC](https://forums.unrealengine.com/t/better-way-to-do-this-instead-of-just-casting-to-all-objects-to-see-wich-one-is-the-right-one/1906124/3 "2024-06-17T13:36:48Z")

</div>

Holy ■■■■ I am stupid. I totally forgot about blueprint interfaces. Thank you

---

<div class="post-metadata">

**Author:** ![3dRaven](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/3draven/32/906552_2.png) [@3dRaven](https://forums.unrealengine.com/u/3dRaven)\
**Post date:** [June 17, 2024, 1:38pm UTC](https://forums.unrealengine.com/t/better-way-to-do-this-instead-of-just-casting-to-all-objects-to-see-wich-one-is-the-right-one/1906124/4 "2024-06-17T13:38:30Z")

</div>

No problem ;).

Have a great day coding. Hope you make lots of progress now that you’ve got a plan to move forward.

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [July 17, 2024, 1:39pm UTC](https://forums.unrealengine.com/t/better-way-to-do-this-instead-of-just-casting-to-all-objects-to-see-wich-one-is-the-right-one/1906124/5 "2024-07-17T13:39:16Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
