#Trying to make a custom room transition need help
194 messages · Page 1 of 1 (latest)
The code for each thing within the warp trigger
Create and step code for the parent trigger
And I was originally using this video for guidance but it didn't work due to what the engine already has in it
https://youtu.be/xlqFO_fuCEo?si=_wak-AMK06o-n9JJ
This is part 5 of a 6 part series showing you how to make an RPG, good luck!
Support me and these videos on Patreon! https://www.patreon.com/peytonburnham
My Game: https://peytonburnham.itch.io/rose-of-starcross-demo
Discord: https://discord.gg/tFd6RVF
My tweets: https://twitter.com/peydinburnham
My twitch: https://www.twitch.tv/peydinburnham
...
How I wanted it be was
Player walks into door way, transition starts, they cant move, as transition is reversing (to end) player still cant move till its done, its so they dont see the flicker of the camera zooming to that room while transitioning
but they used 2 different systems so Im having trouble with it-
Oh this is pretty simple
Just set the camera position to the player's position on room start
Using camera_set_view_position
im assuming since camera variables refer to the player character as char
it would look something like this?
camera_set_view_pos(char, 0, 0);
where'd you get 0,0 from
oh wait would I just leave it as x, y,
who's x,y
yes, but who's x,y
those x,y are just arguments to the function
also
show code on how you're making your camera follow the player
event_user(0);
_camera=camera_create_view(x,y,width/scale_x,height/scale_y,angle,target,-1,-1,width/scale_x/2,height/scale_y/2);```
if(shake_x>0){
if(_shake_time_x>0){
_shake_time_x-=1;
}else{
if(!shake_random_x){
if(_shake_positive_x){
_shake_pos_x=shake_x;
}else{
shake_x-=shake_decrease_x;
_shake_pos_x=-shake_x;
}
_shake_positive_x=!_shake_positive_x;
}else{
_shake_pos_x=random_range(-shake_x,shake_x);
shake_x-=shake_decrease_x;
}
_shake_time_x=shake_speed_x;
}
}else{
shake_speed_x=0;
shake_decrease_x=1;
shake_random_x=false;
_shake_time_x=0;
_shake_pos_x=0;
_shake_positive_x=true;
}
if(shake_y>0){
if(_shake_time_y>0){
_shake_time_y-=1;
}else{
if(!shake_random_y){
if(_shake_positive_y){
_shake_pos_y=shake_y;
}else{
shake_y-=shake_decrease_y;
_shake_pos_y=-shake_y;
}
_shake_positive_y=!_shake_positive_y;
}else{
_shake_pos_y=random_range(-shake_y,shake_y);
shake_y-=shake_decrease_y;
}
_shake_time_y=shake_speed_y;
}
}else{
shake_speed_y=0;
shake_decrease_y=1;
shake_random_y=false;
_shake_time_y=0;
_shake_pos_y=0;
_shake_positive_y=true;
}
if(!instance_exists(target)){
camera_set_view_target(_camera,noone);
camera_set_view_pos(_camera,x+_shake_pos_x,y+_shake_pos_y);
}else{
var spd = 0.20 //or however fast
x = lerp(x, target.x - width/scale_x/2, spd )
y = lerp(y, target.y - height/scale_y/2, spd )
camera_set_view_pos(_camera, x,y)
}
camera_set_view_size(_camera,width/scale_x,height/scale_y);
camera_set_view_angle(_camera,angle);```
ok
you're using x,y
cool
room start event
if instance_exists(target){
x = target.x
y = target.y
}
that's it
the camera still does that even with that in the room start event
camera_set_view_pos(_camera, x,y)
pop this in too then
ah wait
if instance_exists(target){
x = target.x - width/scale_x/2
y = target.y - height/scale_y/2
camera_set_view_pos(_camera, x,y)
}
that's what needs to go
edited
I removed it now the camera is just locked on a random part of the room
after and I put
if instance_exists(target){
camera_set_view_pos(_camera, x,y)
x = target.x
y = target.y
}
in room start
I probably didn't do it correctly or something
Its working now, is there anyway I can still stop the camera from coming to an abrupt start without that spd variable and keep the solid room transition though
what?
how zetsu described it, the camera comes to an abrubt stop making it look like the sprite shifts to the left or right when it doesn't while the walking animation plays
is there anyway I can still stop the camera from coming to an abrupt start without that spd variable
no
and keep the solid room transition though
what's the room transition got to do with spd
Look im not the best at explaining, what I meant was that spd variable is what caused the camera to do that when switching rooms and by "solid room transition" I just meant when the camera stays completely still when switching rooms
so you want it to stop moving when the transition is happening
instead of still moving a little bit
Basically I wanted to keep that smooth camera from before + Just make the camera move while its fading rooms instead of after
you're making less sense
wdym by make the camera move while it's fading room
move where
this code is supposed to make it be where it needs to be when the room starts
so that the catching up doesn't need to happen
and you said it worked
so idk what you're talking about
maybe a video would help your explanation?
I can do a video yeah, that would probably help better...
give me maybe 10ish minutes if thats fine
no guarantee i'll be around. just post it and if someone can they'll help
Alright
Im slow at explaining...
It fully starts around 00:30
and the second video was me going on about how that tutorial had issues with the code that already existed in the engine.
so...
this didn't work? what event did you put it in what object
the solution doesn't remove the speed variable. the speed variable is still there in the step event. the step event stays unchanged
the code i posted goes in room start
the whole idea is that you're teleporting the camera to where it needs to be immediately at room start, so that it's not needing to do the catch up. then when you move around in your game, it starts having to catch up again and that's your smooth camera
I did put it in room start.
You told me to edit this
var spd = 0.20 //or however fast
x = target.x - width/scale_x/2
y = target.y - height/scale_y/2
camera_set_view_pos(_camera, x,y)
}
to
if instance_exists(target){
x = target.x - width/scale_x/2
y = target.y - height/scale_y/2
camera_set_view_pos(_camera, x,y)
}```
which removes that var spd variable.
in the room start event, yes?
of the camera object?
spd/lerp in step
no spd in room start
yes-
I was in the middle of typing about it before you said something
and if it helps I can show what was in room start prior
🤔 so it wasn't working...hmm
I was gonna paste what I was typing (it did work but I got some general opinions from friends) about whether I should have the camera be the changed or the smooth with the catchup.
Personally for now I'm going to use this edited one you helped me with because its what I wanted initially
What I was typing prior:
They prefer the smooth one but said both works However I have a fairly good use case for this edited one just in case I go back to the smooth one so it doesn't do the whole catchup with specific scenarios (I will not elaborate), and I'm going to retry that tutorial from that video that adds custom transitions (that aren't a generic fade) which will make the camera catchup less obvious hopefully (which was the other half of this question initially...)
Thanks for helping though (sorry that I made things a complicated on accident), I tried my best to explain it in the videos... Also I didn't say it didn't work it was just a hard choice with the camera since I couldn't have one or the other, smooth camera or no catch up .
when you say catch up
you're referring to the catch up in the room transition, right?
yeah...
that's...what i was tryna fix
there are other reasons why the code i gave wouldn't work
you can have smooth camera and have it not do the weird teleporty thing at the start
would you...like to fix it?
yeah I would also
Can I show something in video format rq (gotta make the video) just a side by side of it before and after the change (like how both end up looking (idk it might help)
sure
ok
while you're at it, answer me this:
is your player persistent and gets teleported to where it needs to be when you go to a new room
how the engine works it requires the player object in each room (it breaks if its persistent) I can show the player stuff too if you want.
so it's not persistent
well that ruins that theory
hmm
if the player isn't persistent then the issue isn't what i think it is
show me all your camera's code again
one video coming up (I'll need a few minutes)
show camera code in screenshots please i don't wanna pause videos for code
ok mb
makes it really hard to refer back and forth
fair enough
step may require 2/3 images in itself so I'll separate those 3 when sending
the three at the bottom of room start are default for said engine I probably put camera_set_view_pos(_camera, x,y) in the wrong order-
The user event is just a camera shake event I dont think I would affect this
Adding step now
your room start code is wrong
event_user(0)
view_enabled = true
view_camera[0] = _camera
view_visible[0] = true
if instance_exists(target){
x = target.x - width/scale_x/2
y = target.y - height/scale_y/2
camera_set_view_pos(_camera, x,y)
}
x = target.x
y = target.y
was old code, pre correction
OOOOOO
omg-
im actually dumb
this whole time I didn't think you were telling me to put
x = target.x - width/scale_x/2
y = target.y - height/scale_y/2
camera_set_view_pos(_camera, x,y)
}```
In room start too...
"was old code, pre correction" why am I not surprised that I managed to mess that up
ok well the camera still does the catch up even with that
repost your step event again?
oh you never showed your step event
that code should basically match the step event
just without the spd and lerp part
Unchanged step event
if(_shake_time_x>0){
_shake_time_x-=1;
}else{
if(!shake_random_x){
if(_shake_positive_x){
_shake_pos_x=shake_x;
}else{
shake_x-=shake_decrease_x;
_shake_pos_x=-shake_x;
}
_shake_positive_x=!_shake_positive_x;
}else{
_shake_pos_x=random_range(-shake_x,shake_x);
shake_x-=shake_decrease_x;
}
_shake_time_x=shake_speed_x;
}
}else{
shake_speed_x=0;
shake_decrease_x=1;
shake_random_x=false;
_shake_time_x=0;
_shake_pos_x=0;
_shake_positive_x=true;
}
if(shake_y>0){
if(_shake_time_y>0){
_shake_time_y-=1;
}else{
if(!shake_random_y){
if(_shake_positive_y){
_shake_pos_y=shake_y;
}else{
shake_y-=shake_decrease_y;
_shake_pos_y=-shake_y;
}
_shake_positive_y=!_shake_positive_y;
}else{
_shake_pos_y=random_range(-shake_y,shake_y);
shake_y-=shake_decrease_y;
}
_shake_time_y=shake_speed_y;
}
}else{
shake_speed_y=0;
shake_decrease_y=1;
shake_random_y=false;
_shake_time_y=0;
_shake_pos_y=0;
_shake_positive_y=true;
}
if(!instance_exists(target)){
camera_set_view_target(_camera,noone);
camera_set_view_pos(_camera,x+_shake_pos_x,y+_shake_pos_y);
}else{
var spd = 0.20 //or however fast
x = lerp(x, target.x - width/scale_x/2, spd )
y = lerp(y, target.y - height/scale_y/2, spd )
camera_set_view_pos(_camera, x,y)
}
camera_set_view_size(_camera,width/scale_x,height/scale_y);
camera_set_view_angle(_camera,angle);```
where is target set?
to the player object
cuz i see it's getting set to noone in your user event 0
which means in room_start that code doesn't run, because instance_exists(noone) is false
but i don't see where you set target=obj_player
is that in another object?
Im looking
ctrl shift f, project wide search for target=
this is in the player code
Nothing that I can find so no apparently
char_id=0;
res_idle_sprite[DIR.UP]=spr_char_frisk_up;
res_idle_sprite[DIR.DOWN]=spr_char_frisk_down;
res_idle_sprite[DIR.LEFT]=spr_char_frisk_right;
res_idle_sprite[DIR.RIGHT]=spr_char_frisk_right;
res_move_sprite[DIR.UP]=spr_char_frisk_up;
res_move_sprite[DIR.DOWN]=spr_char_frisk_down;
res_move_sprite[DIR.LEFT]=spr_char_frisk_right;
res_move_sprite[DIR.RIGHT]=spr_char_frisk_right;
moveable=true;
_moveable_dialog=true;
_moveable_menu=true;
_moveable_save=true;
_moveable_warp=true;
_moveable_encounter=true;
_moveable_box=true;```
because that code runs
ok
what's in event_inherited()
what's in the player's parent?
char_id=-1;
dir=DIR.DOWN;
dir_locked=false;
talking=false;
move_speed[DIR.UP]=2;
move_speed[DIR.DOWN]=2;
move_speed[DIR.LEFT]=2;
move_speed[DIR.RIGHT]=2;
move[DIR.UP]=0;
move[DIR.DOWN]=0;
move[DIR.LEFT]=0;
move[DIR.RIGHT]=0;
collision=true;
_collision_list=ds_list_create();
var proc=0;
repeat(4){
res_idle_sprite[proc]=(sprite_exists(sprite_index) ? sprite_index : spr_default);
res_idle_image[proc]=0;
res_idle_speed[proc]=0;
res_idle_flip_x[proc]=(proc==DIR.LEFT ? true : false);
res_move_sprite[proc]=(sprite_exists(sprite_index) ? sprite_index : spr_default);
res_move_image[proc]=1;
res_move_speed[proc]=1/3;
res_move_flip_x[proc]=(proc==DIR.LEFT ? true : false);
res_talk_sprite[proc]=(sprite_exists(sprite_index) ? sprite_index : spr_default);
res_talk_image[proc]=1;
res_talk_speed[proc]=1/2;
res_talk_flip_x[proc]=(proc==DIR.LEFT ? true : false);
proc+=90;
}
res_override=false;
_talking_previous=!talking;
_dir_previous=-1;
_move_previous=-1;```
you can also do a project wide search for alarm[0]=
ok well I overlooked that then
var warp_landmark=Flag_Get(FLAG_TYPE.TEMP,FLAG_TEMP.TRIGGER_WARP_LANDMARK);
var warp_dir=Flag_Get(FLAG_TYPE.TEMP,FLAG_TEMP.TRIGGER_WARP_DIR);
if(warp_landmark!=-1&&instance_exists(hint_landmark)){
var lx=x;
var ly=y;
with(hint_landmark){
if(landmark_id==warp_landmark){
lx=x;
ly=y;
}
}
x=lx;
y=ly;
}
if(warp_dir!=-1){
dir=warp_dir;
}
Flag_Set(FLAG_TYPE.TEMP,FLAG_TEMP.TRIGGER_WARP_LANDMARK,-1);
Flag_Set(FLAG_TYPE.TEMP,FLAG_TEMP.TRIGGER_WARP_DIR,-1);```
room start for player
we need to match that for the camera
to make sure our camera teleportation runs after the player sets itself to be the target
//Camera room start
event_user(0)
view_enabled = true
view_camera[0] = _camera
view_visible[0] = true
alarm[0] = 2
//Camera Alarm 0
if instance_exists(target){
x = target.x - width/scale_x/2
y = target.y - height/scale_y/2
camera_set_view_pos(_camera, x,y)
}
frankly starting to not be a fan of this system, it wasn't originally built for this
I added it, I'll test it
wait
your camera doesn't already have an alarm 0 event right?
just to be sure
the camera system i usually use does
ok that's fine then
if it did we'd need to put it in alarm[1] so it doesn't overlap, that's all
Honestly, this things code is so wack, Adding the alarm didn't work- Im losing mind over here
nope
all I did was add the alarm
that makes more sense...
too much in alarm 0
not in alarm 2
omg
your room start is also wrong
you're all sorts of confused
ok
clear your room start
clear your alarm
event_user(0)
view_enabled = true
view_camera[0] = _camera
view_visible[0] = true
alarm[0] = 2
room start
that's it
once you're done with that
Alarm 0
if instance_exists(target){
x = target.x - width/scale_x/2
y = target.y - height/scale_y/2
camera_set_view_pos(_camera, x,y)
}
just that
once you're done
show me both events again
Im praying this works rn ngl
code working on first try is a miracle
OMG
FINALLY
especially working with someone else's code
And yeah ik its never gonna work first try (I mean it might but rarely)
Tysm dude- holy-
Nope nope
all good
cuz before you leave
i have one question for you
do you know what we did and why that fixed things
I cant fully explain with typing it but I do have a good general understanding of what we did and how it fixed it, + I can come back here to refer back to it if needed
So thank you, I can tell ya this different from lua and honestly still understanding game maker but again I do understand how what changes were made helped
alright
as long as you're somewhat following and not just blindly copying and pasting code