How to fake 3d with per-object parallaxing

0 favourites
  • 9 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • Hi everyone,

    was wondering how to best do a simple per-object parallaxing to create a fake 3d effect, like they do e.g. on the trees in Darkwood?

    Subscribe to Construct videos now

    Using C2's layer parallaxing is hard to control; perhaps this is something to best do in a dedicated behavior? (not like I was capable of that ...) I imagine a container of two objects, one on the ground, staying in place, the other one panning within a height-dependent offset, based on it's position on screen - assuming that the player is always in the center of the screen.

    Does anyone know of available solutions or approaches for this kind of thing?

  • facecrime I found that this sort of technique works better if you use scaling on layers rather than parallax.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • facecrime

    you set a global variable " screen distance from camera" [Bz]

    (this represents your eye distance to the projection screen (you game window) )

    and every 3d object has as "distance from camera" instance variable [Az]

    then the scale / position of any 3D object is directly related to the "screen distance from camera" variable divided by the "distance from camera" instance variable

    eg scaled size = original size * Bz/Az

    and x or y position from 0 is original x or y * Bz/Az

    its quite simple if you keep every thing in the 2 d plane with no rotation

    here is an old vid where I had it in action

    it is explained better on wiki link below, ignore all the big matrix maths (this is all including rotation) and just go to the last picture at the bottom of the page. (which we can use in 2 d games for simple pan and zoom)

  • mekonbekon

    that sounds interesting, not sure how this would work, are you saying you'd scale entire layers?


    thanks for the writeup! the logic sounds straight forward enough. Now I'd love if there was a behavior to assign to my object families, else I could only think of going through tags to mark the scaling objects and have a bnuch of new variables on each of these objects to set all those depth parameters.

    Would you have better concepts to assign logic to the objects?

  • facecrime

    Like this: ... r.c3p?dl=0

    You need to make sure that the layout is set to unbounded scrolling in its properties.

    You can fiddle around with the layer scale to adjust the depth of each layer. It's also worth playing around with the layer scale-rates and the overall layout scale to create some interesting effects.

  • mekonbekon

    that's it I expected parallaxing to do that for me.

    beautifully easy solution, thanks for the example also!

  • facecrime You're welcome

  • hey no fair you said you wanted per object .....

    anyway yea , better to use layers like mekonbekon has done

    I tried out the per object theory in my in-work shmup just to see , the buildings you see are using the per object parallax on a single layer

    so it works but not its not very performant. as you are kind of trying to do stuff the gpu should be doing, interesting though.

  • NetOne

    Oh cool! You're right its not per object in fact, wasn't aware i was just approaching Layers the wrong way ...

    Your game looks super flashy btw, curious to see that when its done!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)