#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# Problem with change attribute

Posts: 59Member
edited 12:10AM
Hi

I'm working on a new game and have a really weird problem.
I need to stop my scrolling background when some conditions are reached.
So I put an attribute scrollstop to my game when scrollstop=0 scroll is working when scrollstop=1 background scroll stops. I put an actor for testing with rule when I press space attribute change and scroll stop.Eveything works ok.
Now I want to stop the scrolling when distance between two actors are equal 352.
So I put constrain attribute to a new attribute called distance where distance is actor1 x position - actor2 x position.And now when distance=352 change attribute scrollstop to 0.
It doesn't work!!!!
For testing purposes I put an actor with display text behavior to watch distance attribute and see what is happening.
When distance reaches 352 nothing happened, scrolling don't stop and attribute doesn't change.
What's going on?
I even tried abs and floor functions to determine the exact value and nothing. This is crazy.

• Posts: 914Member, PRO
have you tried just changing the attribute and not constraining it?

Rule
when (position x actor 1- position x actor 2) = 352
or when (position x actor 2- position x actor 1) = 352
change attribute scrollstop to 0

Giacomo
• Posts: 59Member
this is totally crazy, I just put a rule when self.positionx=250 destroy actor.
put an actor with display text position x to watch the actual position and when it reaches 250 nothing happened.

Maybe GS Messed up somehow and I need to reinstall it?
This is impossible to basic rule doesn't work.
• Posts: 914Member, PRO
Yeah, try reinstalling. Not sure what the problem is there. Does this happen only in one project?
• Posts: 1,802Member
I dont think thats a glitch. Your rule says it has to equal exactly 250, so for example if your moving something using the accelerate behavior then chances are its not gonna land on exactly 250(Maybe 250.7, 250.1, etc). Same applies to your problem. I dont think its likely that the distance between the actors will equal exactly 352. Don't know if this is helpful at all, but its the first thing that popped in my head

Maybe try using greater than or less than??
• Posts: 59Member
Just reinstalled and it don't help.
I have a move behavior on actor no accelerate and as I said I tried also abs and floor to get even numbers and this also doesn't help.
I think I will back to 9.4 and wait until 9.5 is fixed. My previous project doesn't work at all on 9.5 , it used camera.origin attribute and 9.5 freezes when you try to use it. It seems that 9.5 is totally messed up and unusable.
• Posts: 59Member
Ok, I got it. There should be exactly 250 for example, when using move behavior but GS doesn't check that often to catch that moment. So the solution is to use floor function and I was using it wrong previously.

For everyone who don't know what the floor function is. This function round down a decimal to nearest integer.
This discussion has been closed.