Can attributes work across layers?
-
-
@iTap-Development did you select an object to set the attribute on? I'm pretty sure global can't have any attributes on if so you have to select an object.
-
Attaching screen grabs. The one with Started touching is the layer that has the object with the attribute. It works. The other is a different layer. It does not work. Thoughts?
-
@This in the first one, it is getting the attribute straight away. Is it at 1 from the start or does it get set to 1 after the get attribute has already run? Maybe share the download link.
-
@Jack8680 oh, I don't think I set an object on the global part🤔 that probably what's wrong😃
-
Yeah, right now you can't set attributes on the global object. So you need to select an object to set an attribute on. The easiest way is to create an object on global UI, which will do what you want it to do.
-
So, I've created an empty object on the global UI level with an attribute. The default value of that attribute is 0. I have a rule on one layer that sets the attribute value to 1 when an object is touched. I have a rule on another layer that is pictured in the first screen grab above: behavior bundle, get attribute, if attribute is greater than 0, execute behavior. The only thing I can think of, does get attribute not constantly check to see if the attribute has been changed?
-
@Hamed will it work on global if you just select an object for the attribute?
-
@iTap-Development Just tried it. Doesn't work. I think it might have something to do with the second layer not being aware that the attribute has been changed. Does "get attribute" constantly check to see if the attribute has changed or just do it once upon launch?
-
Okay, I can get it to work, if I add a Start Touch behavior, which is not what I want it to do. I think I now understand that "get attribute" either executes immediately in launch or executes when it is triggered. What I am trying to figure out is how to have a behavior that is constantly monitoring for a change in the attribute. In the attached screen grab, I can get the left column to work, but the right column doesn't. The right column is what I would like. Anyway to achieve this?
-
If you need a constant check, use a timer of 0 (ie. check every frame)
Usually timers of zero means that there is probably a better way of doing it. So if you know when you should update the attribute, its probably better to do it once.
-
@Hamed Got it. Set timer to .1 and that worked. WIll the timer make it run slower?
About an easier way, are there ways in HP for behaviors to automatically be aware of when attributes change?
-
@This if you want it to happen every time the attribute satisfies a condition, you could use an execute behaviour in the objects that set the attribute, executing the get attribute and check if it's greater. That way, it checks if the attribute is greater than one every time you change the attribute.