-1

I am trying to learn how to develop games with Unreal, and I am currently following this tutorial series: https://www.youtube.com/watch?v=9f98-D9T0Nk&ab_channel=TheGameDevChannel

Now I am at the part where I should be able to place items from the HUD to the world. I was able to replicate the HUD and its functionality of being able to choose buildings and placing them in the world. However, I am currently running into an error everytime I click on a building twice in succession (to deselect). But, if I select a different building after the first selection, I do not run into the error. e.g.

  • Click item 1 > Click item 1 | error
  • Click item 1 > Click item 2 | no error
  • Click item 1 > Click item 2 > Click item 1 | no error
  • Click item 2 > Click item 2 | error
  • Click item 1 > Click item 2 > Click item 2 | error

Here is the error: enter image description here

For context, here are screenshots of the blueprints affected: enter image description here

enter image description here

I have tried checking the video's comments but no one has encountered said error. All I know is that if I select on the same building twice, it runs into the error but I am not sure specifically why that happens. Please let me know what I can check to fix. Thanks!

pauloutboy
  • 31
  • 5

1 Answers1

0

PlaceableActor did not exist at the moment those functions were called. Make sure you link PlaceableActor to an IsValid node before accessing it, in both your Refresh Placeable Building and Update Placement function to fix the errors.

Inside Refresh Placeable Building, double check that SpawnActor node did in fact return you a valid actor reference. SpawnActor could fail if the class is not valid. Refer to your PlaceableActorType node (the purple node). You can right click on any blueprint node (with an exec pin) and select Enable Breakpoint so you can step through and inspect your code.

Inside Update Placement, before even executing a line trace, make sure that Placeable Actor exists by placing an IsValid node at the very start of the function before doing anything.

Ali
  • 1
  • 3