AR Foundation - How to delete() objects after instantiating

Hello everyone!

Recently I tried ARFoundation after I used Vuforia in my last projects. And especially for the projects that have plane detection I love it. ARfoundation seems to be in the better place here. Although I can’t debug ARfoundation since it doesnt seem to use the webcam as Vuforia does… right? Also remote device is still not available, right?

What I need in my project is to remove the last placed object. I spawn this object with Instantiate unpon touching the display.
5278716--528948--upload_2019-12-13_11-28-47.png
Object to place is a public GameObject that is passed to the script.
5278716--528951--upload_2019-12-13_11-30-30.png

I tried now to get a bool variable objectIsPlaced. It is set true when place. If another touch is recognized and if objectIsPlaced is true the object should be deleted.
5278716--528954--upload_2019-12-13_11-52-43.png
I tried it that whay but also with this.objectToPlace.

Thank you for your help!

did you get the solution?

Instantiate returns the GameObject instance which was created. To destroy that instance, you need to save it to a variable perhaps, then Destroy that, not the objectToPlace Prefab.