Hundreds of features to explore
Games made in Construct
Your questions answered
Popular & trusted by schools and Universities world-wide
Construct 3 runs in the browser & works offline
Students do not need accounts with us
Our educational partners
Free education resources to use in the classroom
World class complete documentation
Official and community submitted guides
Learn and share with other game developers
Upload and play games from the Construct community
Game development stories & opinions
I'm experimenting with opacity change depending on a distance, and would want to do it between couple of ranges, like 1000 an 1100, where at instance of 1000 would give 100 opacity and 1100 would give 0 opacity. So i tied using clamp, and tried some to other ideas, but don't know what would be the easiest solution for that. So if anyone would have a suggestion, I'd appreciate it.
clamp((1100 - distance(x,y,x,y)),0,100)
distance = 1100 > 1100 - 1100 = 0
distance = 1000 > 1100 - 1000 = 100
distance = 2000 > 1100 - 2000 = -900 > clambed on 0
distance = 500 > 1100 - 500 = 600 > clambed on 100
distance = 1050 > 1100 - 1050 = 50
For a generic linear interpolation formula you can use lerp(100,0, clamp((distance - distanceForFullOpacity) / (distanceForFullTransparency - distanceForFullOpacity), 0,1)).
with this lerp(100,0, clamp((distance - distanceForFullOpacity) / (distanceForFullTransparency - distanceForFullOpacity), 0,1)) after filling it up it didn't work properly, untill I've switched places for the first two numbers ( so from 100,0 to 0,100) and it worked. Thanks!
Develop games in your browser. Powerful, performant & highly capable.
Oops! Must have inverted some numbers along the way.