Jump to content

How to fix an attribute from changing over time


Recommended Posts

Hey guys, 

Let's say I have  bunch of box objects that are animated and they are going up and down repeatedly randomly.

I want to set my "active" attribute once a box goes beyond Y axis 5 value high, How do I set it ? so once a box exceeds the limit it will stay at active.

My problem is since the object is going up and down, it becomes active and then when it goes below Y axis 5,  the active value will turn into 0 again. I want it to stay active once it reached the threshold. It should be changing progressively. How do I do that? cheers!

Link to comment
Share on other sites

 

23 minutes ago, Andrea said:

Here is a quick example I had saved. The solver takes the attribute active from the previous frame if the condition is not met. If the condition is true than it will assign a value of 1 to the attribute.

attribute_retention.hip

Andrea thanks a lot for your respond, it will take me some time to understand how that sop solver works as a beginner but that definetely looks like what i need again thanks!

Link to comment
Share on other sites

It's nothing special, just keep in mind that the solver is a.. solver. Every frames depends from the previous one starting from the first frame. I banged my head on the wall many times trying to understand how they work :) 

 

Inside the solver you can know the value in the current frame (white colored node) and the value of the previous frame ( violet colored node).

Everything I have done is adding the wrangle and writing a short expression.

What it says is:

step 1. import the value of the previous frame from the second input.

step 2. If in the previous frame the value of the active attribute was zero and the current height (@P.y) is above a certain value -> set active attribute to 1

step 3. If one of the two previous conditions aren't met, so @active is alreay 1 or @P.y less than the threshold, it keeps the value from the previous frame. 0 if it was zero and 1 if it was 1. That's why this concept is usually called attribute retention.

 

Hope it helps a little

Link to comment
Share on other sites

4 hours ago, Andrea said:

It's nothing special, just keep in mind that the solver is a.. solver. Every frames depends from the previous one starting from the first frame. I banged my head on the wall many times trying to understand how they work :) 

 

Inside the solver you can know the value in the current frame (white colored node) and the value of the previous frame ( violet colored node).

Everything I have done is adding the wrangle and writing a short expression.

What it says is:

step 1. import the value of the previous frame from the second input.

step 2. If in the previous frame the value of the active attribute was zero and the current height (@P.y) is above a certain value -> set active attribute to 1

step 3. If one of the two previous conditions aren't met, so @active is alreay 1 or @P.y less than the threshold, it keeps the value from the previous frame. 0 if it was zero and 1 if it was 1. That's why this concept is usually called attribute retention.

 

Hope it helps a little

Got it man thanks a lot very clear explanation!  After I looked at your scene I made something similar from scratch and it worked then I made another simple scene (simplified of my actual scene that i am trying to build) to test again but it's not working could you take a look at it? Problem is spheres are suddenly going active =1 (red)  before even exceeding the given "P.y" threshold. Cheers!

SOP_Solver_Problem.hipnc

Link to comment
Share on other sites

Hi, sorry that's my fault. When I gave to you the project file I assumed that there was just one point in the scene.

In the wrangle I wrote

int prev_active = point(1,"active",0);

 

But this was importing the active attribute from the only point in the scene, which is 0. Instead if you have multiple points (and only if the point count is constant during the timeline) it should be:

int prev_active = point(1,"active",@ptnum);

 

Edited by Andrea
  • Like 1
Link to comment
Share on other sites

11 hours ago, Andrea said:

Hi, sorry that's my fault. When I gave to you the project file I assumed that there was just one point in the scene.

In the wrangle I wrote


int prev_active = point(1,"active",0);

 

But this was importing the active attribute from the only point in the scene, which is 0. Instead if you have multiple points (and only if the point count is constant during the timeline) it should be:


int prev_active = point(1,"active",@ptnum);

 

works like a charm man thanks! 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...