You probably need to switch the camera target character in the module too.
Can a module have its own game_start and repeatedly_execute_always?
I mean, you can probably just do "targetCharacter = newPlayer" before calling "SetAsPlayer"?
Can a module have its own game_start and repeatedly_execute_always?
Yes, every module can have these, they are called in the same order modules are in the project.
Sure, that works. I'm just confused by stuff that should be working but doesn't (like the assigning player as target character, which should happen automatically).
// v1.7 - Added targetCharacter pointer to make camera animation
// possible without switching player characters.
Good to know. BTW, something I've been asking myself these last few days and I'm really curious about: which one gets called first when a room loads? room_Load, or repeatedly_execute? Or in other words, does repeatedly_execute start ticking as soon as the room is loaded, or after fadein?
Sure, that works. I'm just confused by stuff that should be working but doesn't (like the assigning player as target character, which should happen automatically).
It looks like the module it is not intended to switch to player character automatically, it only does at game start and if targetCharacter is not set (targetCharacter == null).
According to the comments to targetCharacter variable it was made so that you can aim camera at non-player character:Quote// v1.7 - Added targetCharacter pointer to make camera animation
// possible without switching player characters.
Good to know. BTW, something I've been asking myself these last few days and I'm really curious about: which one gets called first when a room loads? room_Load, or repeatedly_execute? Or in other words, does repeatedly_execute start ticking as soon as the room is loaded, or after fadein?"Room load" is called first before anything else. "repeatedly_execute" is only called after fade-in, because transition is a blocking operation.
Furthermore, if I do:Code: Adventure Game Studio
targetCharacter = player; cTestCharacter.SetAsPlayer();
<...>
...then the previous player character ALSO gets teleported to room 51 and the viewport stays fixed on him, even though I am actually controlling cTestCharacter because I literally just set it as the player. It's the absolute weirdest thing.
Not sure (this thread starts to confuse me a little)
but maybe there's a misunderstanding of what "player" is? Just in case, "player" is not a special value that will automatically switch the variable to player all the time, it is a Character* pointer that directs to current player.
In above code you set targetCharacter to current player character, and then switch player control to another character. But targetCharacter will stay the same. This is why both characters end up in the room (module teleports targetCharacter to where current player is located).
Or change the order of operations:Code: Adventure Game Studioso you assign new player, and then assign new player to targetCharacter.
cTestCharacter.SetAsPlayer(); targetCharacter = player;
QuoteOr change the order of operations:Code: Adventure Game Studioso you assign new player, and then assign new player to targetCharacter.
cTestCharacter.SetAsPlayer(); targetCharacter = player;
Would this work, though? Wouldn't the room change from setting cTestCharacter as player be effective immediately, thus keeping the next line from running?