Jump to content

Can't access a value changed by callback function


photo

Recommended Posts

Hi,

 

I have a variable a = 0.

 

It is changed to 5 in a callback function. 

 

But onUpdate function I get 0 not 5. How can I access new value?

int a = 0
Body right_holder_body;

right_holder_body.setContactCallback(functionid(onColl));

void onColl()
{
a = 5;
log.message("%d",a); // Output: 5
}

void onUpdate()
{
log.message("%d",a); // Output: 0
}

Thanks.

Link to comment

Hi Yiğit,

 

could you please clarify the scopes of your code? It doesn't clear, what namespaces or classes variable and body declaration belongs to, and from what place onUpdate method get called. It will be better, if you provide full minimum working sample code.

Link to comment
×
×
  • Create New...