Code gives error

This code:




Is giving this error:


image

But I have no idea why.

1 Like

That’s because ItemActor is a reference to HitActor, and not a copy; it means that it’s the same object, but you have two different pointers to it: HitActor and ItemActor. When you call Destroy() on HitActor, you effectively destroy the object referenced by ItemActor, and then you’re trying to do stuff to it, but it’s pending kill.

2 Likes

I want to make it so you inspect the item for 2 seconds and then it gets removed from the screen. What would I need to change?

Don’t destroy HitActor until everything is done.

But if I wouldn’t destroy the HitActor first there would be 1 object still in the map and 1 object in front of the player right?

Wait, I misread the BP a bit. You’re not setting the value of ItemActor, you’re setting its child actor class. But do you ever set its value anywhere?

erm

1 Like

Only the relative start location and the Relative Scale/Location of updated timeline

I need the item in the world be removed. Then you can see the item on the player and then the item gets deleted from the player screen within 2 seconds.

Create an event to destroy the actor. Do all the stuff you want…inspect etc. Call the destroy actor event “AFTER” the item has been added to inventory.

When testing the code it works fine? the error just show up when you quit the game? if this is the case you can drag an IsValid? node from ItemActor on the timeline Update, and if ItemActor is valid set relative scale and location. Do the same on the timeline Finished, before the Branch, if ItemActor is valid go on with the inspecting? Branch.

1 Like

Works perfectly, thank you!

1 Like