How do I…
I’m using an extension. I created three instances of an object which is set to alpha=0 to make them invisible. I want them to fade in one by one by tweening the respective object variable, instance after instance.
What is the expected result
The value of the object variable opacity is tweened to 1.
What is the actual result
Gdevelop gets stuck when it reaches the tween line and does not continue performing actions. It seems like there is a typo or a syntax error, but I cannot find it.
IDK if this is the only problem but opacity goes to 255 not 1.
Thanks for the hint. I forgot that there is a dedicated tween to opacity. I did it via an effect whose value was synced with an instance variable. For the effect, the range is from 0 = transparent to 1 = opaque.
The question is: What’s wrong with the tween action? Like I said, gdevelop can’t go beyond this action for some reason.
As long as the default ID is 99. The only thing I see or dont see is an action to set the opacity to zero. Tweens all work from the current value. If it’s already 255 then nothing will happen.
The object is transparent by default (alpha in the effect is set to 0). So they are being created invisible and - are supposed to - fade in by slowly tweeting the variable.
I’m confused. Are you using a tween for the opacity or an object effect. If you’re using an object effect then you would need to change it’s transparency setting. The effect would just undo any changes you make.
I don’t believe you can tween effects directly. You can tween an object variable to 1 (make sure it’s zero first) and then with a tween is playing set the object effect setting to the value of the object variable. The downside is this would require an action that can run on every frame to be able to update the setting.
Edit: I didn’t notice that you were tweening a variable. Are you setting the effect to the varible somewhere?
Yes, that is what I found out (not possible to tween object effect directly, thus using a variable as proxy).
The sync between the variable and the object variable happens outside the extension and works. If I set the variable in the debugger to 1, the object becomes visible instantly. It also works if I set the object variable directly, just the tween does not work for some reason on the object variable.
I am using an object effect to adjust the opacity since I wasn’t aware that there is a dedicated tween on that.
I was just about to give up. It just came to me. I hope. After the object parameter you need to add a parameter of the type “behavior” and choose the tween behavior. IDKW but with extensions you need to add the behavior as a parameter. It doesn’t require anything else. Just the parameter.
Yes, I am aware of that. I wasn’t able to set tween up before I added the behavior as a parameter. You can see the name of parameter 4 is behavior, it just did not fit all in the screenshot.
IDK, maybe it needs to be the very next parameter. Currently it might be pointing at the layer parameter.
Edit: I just tested it and it doesn’t seem to matter where the parameter is.IDK. I’m out of ideas.
I wasn’t sure on this either. But it says „previous object“, and it did not show any red in the tween action after I added the behavior parameter. But it’s worth a try!
I changed the order of the parameters, did not make a difference. Still stops at the tween object variable action.
I’m not sure how to tackle this differently. It’s the same when tweeting the opacity directly. Like it cannot use tween there or this way. It’s so weird.
I’ve been testing it but something weird is happening. With the tween enable it’s causing the entire function to repeatedly loop. The tween doesn’t seem to matter. If I disable the tween, it only runs once.
It keeps adding objects.
So I tried different things, and the problem only exists with tweens that refer to an object. Other tweens behave as expected. As soon as the object is referenced (e.g., for adjusting an object variable or adjusting the opacity of an object instance directly), the system stops continuing as soon as it hits this action.
If you look at the screenshot:
I can set the variable “context” to 7 for the first fitting instance, but gdevelop gets stuck on the next step - which is a tween on the very same variable of the very same object instance.
I don’t get it. And I don’t know how to debug this any further.
IDK, it started to work for me. IDK if I changed something. But the variable tween works and just tweening the opacity directly works.
in the extension variable tween
in the scene
in extension opacity tween
I switched to utilizing a behavior for it (which is more suitable anyway since it affects all instances of the object) and this works.
Anyway, thanks for sticking with me! That was a rather frustrating one.
sounds like a plan. Let’s call this one [solved] and never speak of it again.