[SOLVED] Add/remove trait when entering/leaving from area (floor, room, ect.)

hello guys, greetings

I need help regarding adding a trait to another (empty) when my (player) first collides with a certain object and when he stops being in contact with said object, the trait of the (empty) is stopped/removed to avoid these objects don’t spawn constantly and slow down the game
basically it is, if my character is in a “room” for example, the void will generate obstacles and when my character leaves from the “room”, the void will stop generating them.
the problem that I have in my file is that when my (character) collides with “the room” the game stops but does not close, it is as if all the features stopped working.
I’m definitely doing things wrong but I don’t know what, thank you very much in advance.
pos: I tried to add the feature to the beginning of the (empty) so that it generates the obstacles and stop it in case my (character) collided with another object that I chose but it did not work

my file
Edit: in the file you can see that the (empty) ones I want to add the trait to are children of the objects that will add the trait when my (character) collides with one of them,is what I want to do, when my character is in contact with the floor, the empty has the trait and when leaving the floor, the empty loses the trait


In most cases, this means that the game has stopped due to an error. You can find more information about the error from the debug console, which can be enabled as shown here

In your case, the error reads:

Trace: Error:
Failed assertion:
        Message: Object should not be null
        Expression: (object != null)
    at Function.throwAssertionError (<anonymous>:5047:9)
    at armory_logicnode_AddTraitNode.run (<anonymous>:1217:25)

meaning, the object to which you are adding the trait is Null. Digging deeper, your node logic does not define the name of the child to add the trait to.

This might be the reason for this error. Alternatively, you could also use Contains or Starts/Ends with to specify only a part of the name.

However, I am not sure what you wanted to do in the RemoveSpawner logic tree. I have shown how it can be done in the fixed file below.

I have also switched from On Volume Trigger to On Contact node, since the traits must be added/removed when the player “contacts/touches” the Floor. And not when the player is inside the volume of the Floor.

Here is the fixed file with all mentioned the changes:
(Add)(Remove)Trait_when hit with_Fixed.blend (1.1 MB)


Great, that’s what I wanted, thank you very much
Regarding adding the name of the object (child), the truth is that I did not know whether to put it complete or leave it empty, for fear that it would only have the name of a single (“spawner”)
and (in volume trigger) I use it because of the idea that it is a (room) where the character passes through
(on contact) I used it, but I didn’t know if the (trait) would be added again every time my (character) jumped while in the area.

One more query, with logical nodes (“set trait paused”) can it be done similarly? It is that before removing/adding the function, I had added the (“spawner”) at the beginning and my intention was to pause/resume but I had not found the option to (resume)(“set trait unpaused”)
again thank you for helping me,have a good day :smiley: :slight_smile::smiley: