Replies: 1 comment 3 replies
-
I did it a while ago in a test project, so the following is probably wrong, but can be used as reference. I used a value from 0 to 1 in the shader called "center" for the center position of the effect: https://github.com/manuq/rescue-godot/blob/ef5650cbc5914d1c5fb4bf499ffd14ba67cbe509/scenes/goal_effect.gdshader#L4 And I calculated the position of an object related to the viewport between 0 and 1 with this code: https://github.com/manuq/rescue-godot/blob/ef5650cbc5914d1c5fb4bf499ffd14ba67cbe509/levels/level_01.gd#L21-L25
I think on the way in it is less important. What's important IMO is on the way out (first fading) because it shows the player that they were caught.
I think so, yes! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently when the player is caught in a stealth level, when we reload the scene a radial wipe transition is used.
I think it might be fun to focus the centre of the wipe on the player, like the Iris Out transition in classic Loony Tunes cartoons and also seen in games like Spelunky (see a few seconds of this video.)
Since we already have a radial wipe, I thought it would probably be a simple matter of programming to offset the centre of that texture to be centred on the player. The shader change is small:
Then there's a lot of really tedious programming to thread the values through about 10 function calls to the shader.
The place I got stuck is getting the right position in UV coordinates. On the way out, we need to translate the player's
position
into screen coordinates, then transform that into the range (0,0)-(1,1). (That could also be done in the shader I guess.) I thought I had this right usingplayer.get_global_transform_with_canvas() * player.position
but that gives totally incorrect results.On the way in, it's harder still because we don't know the position until the new scene has loaded, and until the player has been relocated to the spawn point, at which point we can get the location of the player by the same means as on the way out. But that means refactoring how the scene-switch is done.
So at this point I stopped to ask: is this even a good idea? :)
Beta Was this translation helpful? Give feedback.
All reactions