I created my first behavior, a hover animation on sprites objects.
My problem is that the hover animation will execute for all objects on the scene with this behavior and not only for the instance which should behave.
ex : The mouse is on the sprite 1, all sprites with the behavior will execute the animation.
When I defined the behavior I access parameters using the “Object” parameter.
Thank you for your help.
Would you be able to add a screenshot of the code for better clarification? And welcome
Hello, thank you snobunni.
I think I misunderstood the way to create a behavior and the way it should be used in the project.
I wanted to create a full automated behavior just as the “platform behavior”, when you set it on a sprite object, the behavior is active for this instance.
I can send only one picture in this post because I am a new user.
Here is a part of the “doStepPreEvents”
In the OnCreated event I set all the original object size value in variables.
I’m using timer to increase or decrease the object’s size.
Hello @snobunni !
My bad, i complicated my code for nothing. Basing the actions on timers without checking the state of the object it was normal that when the timers condition is true for one It was true for all with this behavior.
I delete the timers and based the code only on boolean conditions and it works fine now.
This “How do i…?” can be marked as “Solved”
You can probably use an id variable. Like when the object has certain id, enable its behaviour, else disable it. If you didn’t get what I meant, you can ask for more explaination :).
Didn’t realise it was fixed. Alright if that’s fixed, I’mma get to my way lol.
I’m glad you found a solution!
For your future reference (and anyone else who finds this thread), the main reason you were having issues with timers is because most of your timers are using “scene timers” in your actions and conditions:
Scene timers will be a singular timer and cannot be behavior specific, you were likely resetting the scene timer with every instance of the object that was in the scene. You should have been using Object timers, which are unique per instance of an object.