playMaker

Author Topic: Destroy Component action throws an error  (Read 395 times)

szomaza

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Destroy Component action throws an error
« on: December 27, 2018, 12:05:41 PM »
Destroy Component action throws an error and stops game when the component that should be destroyed in not there.

LogError("No such component: " + component.Value);

This is not a bug, just how the action is written.

But why is it written like this?
Wouldn't it be better if it just continued without a problem when there is nothing to destroy?
That is what I was expecting.

Of course there is a solution: you can use Has Component action to make sure the component is there and only then destroy if it is found, but this way you need 2 actions to achieve the same thing.
Am I right, or what am I missing here?

Br,
szomaza

Alex Chouls

  • Administrator
  • Hero Member
  • *****
  • Posts: 3627
  • Official Playmaker Support
    • View Profile
    • LinkedIn
Re: Destroy Component action throws an error
« Reply #1 on: December 29, 2018, 12:32:26 AM »
You're right the action could be more forgiving.
I'll update it in the next release.

For now, you could comment out the LogError line:
Code: [Select]
//LogError("No such component: " + component.Value);
I'll probably make it an option (e.g., a Log Error check box) since sometimes it's good to know if it fails when you expect it to work.

szomaza

  • Sr. Member
  • ****
  • Posts: 253
    • View Profile
Re: Destroy Component action throws an error
« Reply #2 on: December 29, 2018, 01:06:47 AM »
Thank you very much for the quick solution for now!
I am learning to be braver editing the scripts with every issue found. Great!

And +1 for leaving the option there.

Thanks!