Concerning Transitions between scenes; Moving the player X pixels from entering edge, handling "Fade-in / Fade-out" sequences. #108
Replies: 7 comments 3 replies
-
That sounds like a bug, and one that should be fixed recently. What version of the addon are you using? Can you try 1.6? In the built-in transition module, this line is responsible for moving the player position: It uses exact room sizes, but you can increase the distance if it causes problems for whatever reason. |
Beta Was this translation helpful? Give feedback.
-
|
Greetings KoBewi- I have updated to Godot 4.5.1 and upgraded to the newer version of Metsys. The issue I ran into still appears to be a problem- during bug testing, if a tester is on the edge of a room and rapidly hits 'left-right-left-right-left-right' and transitions between two cells rapidly, it still breaks the game. I have found the part of your script you referenced and am trying to find a safe work around. System is very much viable / excellent! Just need some transition padding to prevent bug testers from being able to do this. |
Beta Was this translation helpful? Give feedback.
-
|
I have modified the RoomTransition.gd in the following fashion: ## A MetSysModule that handles room transitions.
##
## The module connects to [signal MetroidvaniaSystem.room_changed]. When room changes, the new scene gets is loaded via [code]load_room()[/code] method. If MetSysGame has a player set, the player will be automatically teleported to the correct entrance.
extends "res://addons/MetroidvaniaSystem/Template/Scripts/MetSysModule.gd"
@export var transition_spawn_offset := 32.0
var player: Node2D
func _initialize():
player = game.player
assert(player)
MetSys.room_changed.connect(_on_room_changed, CONNECT_DEFERRED)
func _on_room_changed(target_room: String):
if target_room == MetSys.get_current_room_id():
# This can happen when teleporting to another room.
return
var prev_room_instance := MetSys.get_current_room_instance()
if prev_room_instance:
prev_room_instance.get_parent().remove_child(prev_room_instance)
await game.load_room(target_room)
var new_room := MetSys.get_current_room_instance() # Added! New Code
if prev_room_instance:
#player.position -= MetSys.get_current_room_instance().get_room_position_offset(prev_room_instance)
#prev_room_instance.queue_free()
var room_offset := new_room.get_room_position_offset(prev_room_instance)
player.position -= room_offset
# New direction based off-set.
var dir: Vector2 = room_offset.normalized()
print("Player transition offset is being applied.")
# Horizontal transitions
if abs(dir.x) > abs(dir.y):
player.position.x += sign(dir.x) * transition_spawn_offset
#Vertical transitions
elif abs(dir.y) > abs(dir.x):
player.position.y += sign(dir.y) * transition_spawn_offset
prev_room_instance.queue_free()
I'm still working on getting fade-out, fade-in transitions to work. :) But this seems to have resolved a player being able to "wiggle" on a screen edge / outrun the room transition! |
Beta Was this translation helpful? Give feedback.
-
|
I've created a transition between cells in the following manner: Effects Transitions Between Cells
In the other cell, the ColorRect in the HUD will have to be told when to "fade back in", completing the transition. I've done this with a timer. Player input can be disabled / enabled to prevent the player from 'wiggling' or upsetting anything. These objects could be set to do a variety of things - from starting / stopping music, starting cut scenes, etc -- without upsetting the cell transition logic. |
Beta Was this translation helpful? Give feedback.
-
|
I tried reproducing the issue you are experiencing (I modified the character to move by 1 pixel) and I can't: godot45_YGA166kHSu.mp4The rooms always change as expected. What are you using for transitions? Did you make any modifications? |
Beta Was this translation helpful? Give feedback.
-
|
Here is my Game.gd Annnnd here is the RoomTransistions.gd There are some other issues; for example:
It may very well be something I have done - and I'm having trouble nailing it down. It could also be that my player is a Rigidbody for physics reasons, it could be a collider issue where it doesn't place right, I don't know- but I'll happily share any code you want, or even provide footage if you want. |
Beta Was this translation helpful? Give feedback.
-
|
I just wanted to say - with the edits I've made - things run fine and it doesn't break anymore with offsets. This may be situational and for my project specifically! IF this happens with others - a work around is to just ad a slight offset to player positioning upon arrival in RoomTransitions.gd |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello there! I really appreciate what you've created - and it's been working great for a project I'm working on.
Question: I am attempting do the following:
Why:
I noticed with your system that if the player enters a room - then 'wiggles' left-right quickly - the player will eventually break the map and end up in the wrong cell.
I am trying to 'compensate' for this bug by fading the screen, ... allowing the player to load ... and then "moving" them away from the screen edge so that they cannot 'wiggle' on the edge of the screen.
However, I've been having trouble with this. I've tried to 'pause' the transition to allow the fade out to occur -- but the player then teleports to multiple rooms. I'm not really sure how to 'off-set' the player once they arrive in the new room, either - or how to handle 'fade out' or 'fade ins' between rooms.
Little help? I'm not a professional coder - I'm a spriter - but I know enough code to get by.
Beta Was this translation helpful? Give feedback.
All reactions