1. Hey! Guest! The 32nd GMC Jam will take place between Feb 22nd, 12:00 UTC (Friday noon) and Feb 25th, 12:00 UTC (Monday noon). Why not join in! Click here to find out more!
    Dismiss Notice

It is possible to mix 2d and 3d background in Game Maker?

Discussion in 'Game Design, Development And Publishing' started by joondoe, Jan 23, 2019.

Tags:
  1. joondoe

    joondoe Member

    Joined:
    Jan 23, 2019
    Posts:
    3
    I'm wondering if it is possible to make 2d and 3d game in Game maker like Ori and the blind forest, this kind of stuff ?
     
  2. YellowAfterlife

    YellowAfterlife ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    2,098
    If I remember correctly, the backgrounds in Ori weren't 3d - just a particularly fancy layered parallax effect.

    But yes, you can change projection to 3d, draw something, and change it back - via d3d_set_projection functions in GMS1 or camera functions in GMS2.
     
  3. joondoe

    joondoe Member

    Joined:
    Jan 23, 2019
    Posts:
    3
    thanks for your answer,
    awesome for the Ori work if it is the case,
    okay so it's not an hacky movement if I understand well it's adapted to Game Maker features?
     
  4. sp202

    sp202 Member

    Joined:
    Sep 26, 2016
    Posts:
    936
    It's not difficult to do provided you're somewhat familiar with how 3D works in GMS.
     
  5. Niels

    Niels Member

    Joined:
    Jun 22, 2016
    Posts:
    769
    I believe Ori used the same effect for its parallax effect as hollow knight. This is done by using unity's perspective (3D)camera in a 2D room.
    [​IMG]

    Would love to know if something like this is possible in gms2
     
    SnotWaffle Studios likes this.
  6. YellowAfterlife

    YellowAfterlife ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    2,098
    At the very least you can reposition layers with code as you please (for any logical or illogical parallax)
     
  7. joondoe

    joondoe Member

    Joined:
    Jan 23, 2019
    Posts:
    3
    the work of Hollow Knight is purely awesome
     
  8. Niels

    Niels Member

    Joined:
    Jun 22, 2016
    Posts:
    769
    Maybe setting the matrix for the camera to a perspective view will do the same trick? (matrix_build_projection_perspective)
     
  9. The Sorcerer

    The Sorcerer Member

    Joined:
    Jan 3, 2019
    Posts:
    138
    Absolutely do able in GMS2.

    You can switch between perspective and orthographic as much as you like during the render cycle.

    What is going on in your attached image is actually quite trivial to do. If I get a chance in the next few days I might even throw something together to show how this can be done in GMS2.
     
    Taddio and Niels like this.
  10. Niels

    Niels Member

    Joined:
    Jun 22, 2016
    Posts:
    769
    can't wait!
     
    Taddio and The Sorcerer like this.
  11. Taddio

    Taddio Member

    Joined:
    Nov 16, 2018
    Posts:
    156
    That would be most awesome, this effect has nice potential!
     
  12. The Sorcerer

    The Sorcerer Member

    Joined:
    Jan 3, 2019
    Posts:
    138
    Alright, challenge accepted. I'll see what I can do :)
     
    Niels and Taddio like this.
  13. Taddio

    Taddio Member

    Joined:
    Nov 16, 2018
    Posts:
    156
    That could very well be the greatest crossover between The Matrix and Paper Mario the world has ever seen :D
     
    The Sorcerer likes this.
  14. The Sorcerer

    The Sorcerer Member

    Joined:
    Jan 3, 2019
    Posts:
    138
    Done :)

    Don't judge the art, just judge the technique. :p

    [​IMG]

    The three layers were placed directly in the room editor too. So it makes it easy to throw something together.

    Download the project here and do whatever you wish with it - https://www.dropbox.com/s/wzkwimb68ffa4a1/Flat3DTest.yyz?dl=0

    It's quick and dirty, no warranties :D
     
    Niels, nesrocks and Taddio like this.
  15. Taddio

    Taddio Member

    Joined:
    Nov 16, 2018
    Posts:
    156
    Will try that asap!
    EDIT: Bro, this is just amazing! I can't believe you crammed such an amazing thing in a few lines of code in a single object, honestly.
    I'm definately gonna be using this A LOT.
    Thanks a lot!!
     
    Last edited: Jan 27, 2019
    Niels, nesrocks and The Sorcerer like this.
  16. The Sorcerer

    The Sorcerer Member

    Joined:
    Jan 3, 2019
    Posts:
    138
    No problems at all :)
     
  17. nesrocks

    nesrocks Member

    Joined:
    Nov 6, 2016
    Posts:
    268
    This is really cool indeed. I'll try to understand the functions better later!

    For a fun test replace:
    Code:
    xfrom += 3 * dir;
    
    if(xfrom > 1000 || xfrom < 500)
        dir = - dir;
    with:
    Code:
    xfrom = width-mouse_x;
    yfrom = height-mouse_y;
    By the way, you seem to have two instances of the obj_3d_controller object in the room. I figure only the one on layer main is necessary?
     
    The Sorcerer likes this.
  18. The Sorcerer

    The Sorcerer Member

    Joined:
    Jan 3, 2019
    Posts:
    138
    Oh is there? Must have been a mis-click. Yeah, just delete the extra one. ;)

    [edit]
    Ah, actually I remember duplicating one of the layers when making the scene, so it must have been the main layer I duplicated and that would have gone with it.
     
    Last edited: Jan 27, 2019
  19. sp202

    sp202 Member

    Joined:
    Sep 26, 2016
    Posts:
    936
    I can't figure out why the effect only affects objects on layers above the controller object's layer.
     
  20. Taddio

    Taddio Member

    Joined:
    Nov 16, 2018
    Posts:
    156
    Ehat do you mean? The only "bug" I found was if you go to the other side completely, the top layer STAYS the top layer, instead of becoming the back layer. I'm guessing it's possible to fix with using instances depth and one single layer, but didn't try it yet.
    I spent a good chunk of the night messing with it and start to get the hang of it, it's reeeeeeally cool. Can use it subtle or for drastic effects, it's convincing
     
  21. sp202

    sp202 Member

    Joined:
    Sep 26, 2016
    Posts:
    936
    If you add more layers in the room editor I found that the projection only affects layers that are above the controller object's own layer, otherwise they look like a regular orthogonal projection.
     
  22. Miradur

    Miradur Member

    Joined:
    Jan 16, 2018
    Posts:
    110
    Thank you so much for this great code. Finally a simple way to get the Star Wars text effect
    (at the beginning of the film) :)

    Miradur
     
    The Sorcerer likes this.
  23. muki

    muki Member

    Joined:
    Mar 5, 2017
    Posts:
    202
    I do this in 2D with fancy layer tricks. Directly inspired by Hollow Knight.

    I draw each background layer (view-sized, and from the view) to its own surface. Both tile and object. Apply a shader to it to add depth-of-field/blur and shrink it down slightly towards the center of the surface. Then I stack the surfaces and I get a nice parallaxed depth-of-fielded scenery behind my foreground. The catch is, I had to make my own rendering control object. And some some manual "on layer draw start/end" scripts for the objects.

     
    The Sorcerer likes this.
  24. Niels

    Niels Member

    Joined:
    Jun 22, 2016
    Posts:
    769
    wow this is so awesome!, totally gonna abuse this technique for my next project!
     
    Last edited: Jan 28, 2019
    The Sorcerer likes this.
  25. The Sorcerer

    The Sorcerer Member

    Joined:
    Jan 3, 2019
    Posts:
    138
    Yes, I found this as well when moving layers around in the layer list, etc. Seems to be a quirk GM's layer system.

    For something more robust, I'd certainly recommend manipulating the layers with the matrix functions.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice