I was working on a project and it started acting odd when I was trying to center some objects. I realised the ViewportWidth expression was not giving the desired value. Using it aligned objects off-center. When I tried (ViewportLeft + ViewportRight), it worked perfectly (aligning objects to center). When I logged both values, they were different. I tried the same in a fresh Construct 3 project. There, they were both same. What could cause this behaviour? How do I fix this?
In fresh project:
Develop games in your browser. Powerful, performant & highly capable.
Well width=right-left. When no scrolling is done then width=left+right but only at that spot.
To center something you’d set x to (left+right)/2 or left+width/2
I do this center = ViewportLeft+ViewportWidth/2
The latest releases also have ViewportMidX/Y system expressions which mean you don't need to calculate the mid-point yourself.