[Solved!] Scene Switch Behavior working only some times, even with same code

Biiiscoito

  • Posts: 21
This title was... difficult to explain. Mainly because it is a little complicated, but let's go by parts.

I'm working on a plataformer game, classic Castlevania-ish. I was having a huge chaos coming up with a nice scene switch manager (as most people in here do, I suppose), so I decided to follow The Indie Station's tutorials. I ended up using the same code they used on their RPG game, with some modifications so you could actually have more than one exit on each side of the screen for neatness' sake (and because the gravity settings could mess up a little), etc, etc.

First Issue: the code didn't work if the screens had different sizes. I solved this by -- surprise -- making all the scenes the same size (60 tiles in width, 45 in height). And, neato! It solved.

Kinda.

When I tested this code using 20x15-tiles scenes, it worked wonders. You could go Left-Up, Left-Down, Right-Up, Right-Down, Scene Up, Scene Down and the code would take care of it with absolutely no problem at all.
But. After attaching the behavior on my 60x45-tiles scenes, I noticed that the code works just fine, except when you try to go back to Scene Left UP, Scene UP and Scene DOWN.

If the codes for Scene Left UP and Scene Left DOWN are the same, and only change on the Y position of the player why doesn't it work? Left DOWN works, Left UP doesn't. Right UP and Right DOWN work just fine. And, as I said, on the test scenes, all of them worked.
It is transitioning to the right scene, but the spawn seems to go wrong, as the scene ends up centered at the wrong place (despite that I have codes on every one of the scenes that more the camera to the player every 0.01 seconds), and the actor doesn't show up.

There are no errors. (as in, null pointer or any of the sorts). I Have double checked the camera follow, and checked if the actor is in every scene about 12 times. And I can't seem to find the issue.


-----------

Edit

So, I figured something! For some reason, the original place where the player character is place seems to matter, but I haven't figured out how.  On some scenes, he can be super far from the entry and he's still teleported there. On other scenes, even if he's very close, the behavior doesn't seem to 'catch' him. He just... disappears. The camera does move to where I originally placed him (it centers around that). But the player isn't there. And nothing moves. And no exceptions pop up.
 :o :o :o

So, how to solve it? Any suggestions would be much appreciated!

My code for the scene behavior is attached.

« Last Edit: February 24, 2019, 04:53:16 pm by Biiiscoito »

Biiiscoito

  • Posts: 21
OK. SO. I managed to fix it. And it was actually super simple.

To help anyone having this problem in the future (or so I hope so), I'm going to post my findings here. :)

First up, I'd like to refer to this topic http://community.stencyl.com/index.php?topic=5211.0 and this other helpful topic http://community.stencyl.com/index.php?topic=4453.0 .

What was happening, was that since my actor was there on the scene but not on the 'visible screen', the player was being considered as 'off-screen', so the behavior wouldn't detect him and 'teleport' him.

I feel so silly! Ahhhh.... Maybe I should take a break for today ._.

The code that solved this issue was on the Player character. Under Events, put a When Created block and add a "make Self always active" and voilĂ !

JeffreyDriver

  • Posts: 2101
Don't worry, just learn from it. I still occasionally make simple mistakes.
Current Projects:
The Grand Grimoire Chronicles Episode 1 now on Kongregate!.
I always appreciate useful feedback. Thank you.
www.jeffreydriver.co.uk