How do I do this layout transition?

Get help using Construct 2

Post » Sat Jun 18, 2016 10:58 pm

First this. The key controls dont work for me. I suppose the functions are not in place yet. I have set the platform on default controls to be able to move the player. I had to change the gamepad triggers to a key trigger for the same reason.

You have doorObj.nextLayout set to "test_01" in the properties plane. Dont use the "'s In the properties plane to assign a string to an instance variable. Just test_01 without the ""-tingys.

That event can much easyer. This does allready what you want. And it is not running every tick the player is overlapping a door. Only when the key is pressed (had to change the gamepad trigger, dont have one).

https://www.dropbox.com/s/q0g7aopkpvs3c ... loos-1.jpg

Then there is something that i dont understand. The two player objects are set Global = No, in theire properties. Normaly, if you change layout, they should get destroyed. So you must create them somewhere, but i cant find the creations in your, dang well commented and organised, project.

Normaly, one would set those two objects to global. Global means, once added to a layout, they stay forever. Even if you change layouts. Till you destroy them, ofcourse. Theire instance variables will also survive a layout change. At this moment you move the object to global variables for a new x&y. Hence: Global. If you make those objects global, you could let the door write to instance variables of the player-helper, wich is more elegant, and flexible.

It is common use to start the game in a 'loader layout'. This layout contains the Global objects, it loads everything needed from Local storage, sounds ... etc. And then moves to the actual layouts, taking the Global Objects with it.

If i do so in the project, i get two players on layout change. They are not in layout of test 1 & 2, so they must be created somewhere. But i am to dumb to find the create actions, or i misunderstand something.

Something totaly differend. I dont like the lerp on the camera. Lerp expects static input. If you use non static inputs, the lerp will never reach the destination. Resulting in a restless camera and flickering, because you have pixelrounding set.

Hope i helped. The main problem was the "" in assigning text to instance variables in the properties plane.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun Jun 19, 2016 12:42 am

@99Instances2Go Yes, thanks! and much more in-depth than what I was expecting.
Sorry about not having keyboard input, had it at the beginning but went through several transitions so opted for now to keep it only for gamepad.
I'm not using a loader layout because so far is only a test_bed for different mechanics. In the future the test layout will be my loader layout if that's a good practice, not sure I'm doing it in the right order lol.

I didn't realize PlayerDetect object had to be to global, but now that you point it out, it would make sense. They are created in the Player Ini section and also in main where I set the initial position for PlayerDetect. Then Player containing animations is set to the controller position.

You are right, lerp is horrible, and I didn't even know why lol. Now I'll check a better solution.

Like I said, really good explanation, so now it seems very clear to me. Thanks for your time!

And if you failed to see where I initialize the Player maybe is because I didn't follow a correct way of doing it. It might be kind of messy, even if I try to keep it organized.
B
43
S
12
G
14
Posts: 488
Reputation: 10,570

Post » Sun Jun 19, 2016 7:58 am

Cap the lerp ?

condition: System > compare 2 values .. distance(scrollx,scrolly,objplayerhelper.x,objplayerhelper.y) .. > .. 4
action: do the lerp

Dont renember exact name of that objplayerhelper.

That way, the lerp will not move the camera arround in this shaded circomstances where it cant reach the distination.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Sun Jun 19, 2016 4:16 pm

Thanks, that looks much better!
Now, I created a loader layout, and made me realize my Player layer was global so that's the reason why it was working.
Now, after I set it up properly, I arrived into a new problem. start x & y pos aren't being updated as fast as Player goes into new layout.

In purpose I made floor smaller so Player Controller could fall outside of layout. So Player x and y pos are updated to the door only after this happens. This wasnt happening before making Player Controller global so I suspect there's something I'm not updating in the right place before it changes layouts.
B
43
S
12
G
14
Posts: 488
Reputation: 10,570

Post » Sun Jun 19, 2016 4:36 pm

Nevermind, I found it. I changed a bit some events and forgot to initialize the player starting pos in a new layer using the variables of startXpos & startYpos.
Thanks again for the help!!
B
43
S
12
G
14
Posts: 488
Reputation: 10,570

Previous

Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 33 guests