Scaling object by increasing its y position

I got an object, i want to smoothly scale it up whenever its y position increases and other way round.

The “other way around” tells me you must “remember” the original scale and position throughout the life of the object involved, so create members to store that at initialization.

If the original Y is 5, and it is moved to 7, you can then say the move is +2. To make this +2 relative to the size of the object you may have to get creative in order to know the extents of the object (which you’ll store as members for original scale and position).

If the object size (extents) is, say, 4, and it moved +2, then you want to set scale to 1 + ( 2 / 4 ), or 1.5.

Likewise, if the object, now at 7, moved to 6, the difference being +1 (you judge this from the original Y of 5), you’ll adjust scale to 1 + ( 1/4) or 1.25.

Rinse and repeat. Limit according to reason.

Note, you haven’t said the object should not shrink, but that’s up to you. If it did shrink, say from 4 to 3, you’d set scale to 1 - ( 1/4 ), or 0.75.