Semi 3d perspective in a 2d plane [SOLVED]

0 favourites
  • 13 posts
From the Asset Store
15 x UK WW2 plane sprites with 2 x damage models per plane and matching shadows
  • To be clear from the start, I´m not talking neither about drop shadow shaders, shadow caster behaviour or anything like that.

    It´s a super stupid thing that I have tried several times in the past, but because I´m still not good at programming, I wasn´t able to achieve this in a simple way (I once ended up making every moving object look like different shadow sprites with the actual object/s attached to it with the right altitude, shameful...). In the end the result was the one I wanted, but it wasn´t reliable in any way.

    So the purpose is simple:

    ·A family of objects

    -When one of these is created a shadow sprite attaches to it.

    -Any object is able to move freely on the 2D plane and this shadow sprite is the reference of where the ground is.

    -Thanks to these shadows, objects in the family can simulate altitude by doing things like hopping or jumping.

    -Objects in the family can ride each other (see reference)

    Sidenote: I´ve had many issues with assigning a different object to a family (when one outside of family object does X, all members of a family do X, which is wrong) even though I´ve read about families, any info would be extra awesome!.

    Reference: (credit goes to rubna)

    https://pbs.twimg.com/tweet_video/CKr1NB4WEAAL47t.mp4

    Any help would be really useful! It might come in handy for anyone else looking for a similar effect.

  • I'm not sure if it's what you're looking for, but a pin behaviour seems to do the trick?

    Here's a quick CAPX for reference.

  • purplemonkey Not at all, pin would fix the shadow's position. If you look at the gifs I provided you would notice why it is nothing like that. And as I said, I am not talking about shaders or behaviours, just a little system to manage a sprite's altitude. I think I once saw a similar concept made by R0J0hound , but I couldn't find it anywhere in the forum

  • purplemonkey Not at all, pin would fix the shadow's position. If you look at the gifs I provided you would notice why it is nothing like that. And as I said, I am not talking about shaders or behaviours, just a little system to manage a sprite's altitude. I think I once saw a similar concept made by R0J0hound , but I couldn't find it anywhere in the forum

    I see. Well dang, I think I actually have a CAPX of something similar that I found on this forum a while ago. I'm going to see if I can find it!

    Edit: Looking at the GIF you provided, you could fake it though. Just use animations and all will be well. When the rabbit jumps (using an animation) match that with an animation for the shadow and it'll all look pretty much like that GIF. I've updated the old CAPX for reference.

  • purplemonkey I think you didn´t understand. Your suggestion wasn´t bad at all, but at the beginning of my original post I said that I´ve accomplished this effect many times, but it was unreliable and tedious , having to tweak every affected object individually. It took a really, really long time, it was unstable, it wasn´t automated, it was buggy and it required waaaaay more code than a simple system that can´t be too hard to make and could be applied to any project, ever.

    This system can now actually be made because of families, and other new things that were added. I´ve tried doing it myself, but like I said in my original post, I´ve ran into many problems with families.

    In the first post I´ve listed the things that were accomplished by the previous "systems", so if anyone knows how to implement them or at least give me any clue of where to build a base from I would greatly appreciate it.

    Thanks purplemonkey, though

  • purplemonkey I think you didn´t understand. Your suggestion wasn´t bad at all, but at the beginning of my original post I said that I´ve accomplished this effect many times, but it was unreliable and tedious , having to tweak every affected object individually. It took a really, really long time, it was unstable, it wasn´t automated, it was buggy and it required waaaaay more code than a simple system that can´t be too hard to make and could be applied to any project, ever.

    This system can now actually be made because of families, and other new things that were added. I´ve tried doing it myself, but like I said in my original post, I´ve ran into many problems with families.

    In the first post I´ve listed the things that were accomplished by the previous "systems", so if anyone knows how to implement them or at least give me any clue of where to build a base from I would greatly appreciate it.

    Thanks purplemonkey, though

    All right, yeah I guess I've been a bit tired lately so my reading comprehension seems to be falling behind. That being said, now I'm interested as well and await an expert to come and save the day and enlighten us both!

  • purplemonkey I really hope so too I´ve been having this issue for a long time now...

  • I've been thinking about this in the past and I think I figured out a way, but it still seems a bit "hacky".

    The way I'd do it we would have 3 objects. The shadow, the object the shadow should cast from (we'll call it the player), and an invisible object that would bind the two together.

    Then what you'd actually be controlling would be this invisible object, not the player. This way you could pin the shadow and the player to this object, and when the player wanted to jump you'd unpin him, make the jump, then pin again when he's done.

    About families, if you want to create the same shadow sprite to each object of the family, it's simple - at the start of the layout, create a "For each (ordered)" for the family. This will run through each object in the family that's currently in the layout, then you can use actions like "For each (ordered) familyname -> create "shadow" at familyname.x familyname.y -> Pin "shadow" to familyname.x familyname.y".

    Be sure to order it by familyname.iid too.

    Of course, there's probably a better way, but that's how I'd do it.

  • Thanks for replying, andreyin ! It´s really not a bad idea but it is basically like one of my first attempts, as I said in the first post (You did not control the actual objects, but the shadow sprites). I know pin might look like the easiest rout, but my experience in previous attemps with these hacky strats weren´t reliable at all (sprites would end up misalligned, jumping would be rather buggy etc) so I was thinking about a more wrapped up, simple family system.

    About the families, that´s exactly the info I was looking for! I´ve tried it out and it works like a charm, it really gave me a big sigh of relief, thanks (I was using normal "for each" before, which was seemingly causing the issue)

    Really sorry for making this stupid thing look like a big deal, because it really isn´t. :/

  • Something like this?

    Using the container object both sprites will only reference the one created with it..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • LittleStain It´s kind of the idea, but that example is tied to a grid and is forced to use custom movement behaviour. What I was looking for was something way simpler:

    Concept:

    -A family has a variable that determines which "altitude" the object supposedly has (it only affects it´s Y)

    -When a family member is created, it spawns a shadow sprite

    The actual part where i´m having issues with:

    -The object´s Y plus its "altitude" determines the shadow sprite´s Y

    -Objects of this family can move their X and Y freely at all times, they aren´t tied to their shadow, it´s altitude is added without stopping any motion.

    That is it. I just bringed up the "jumping" in the first place to show how the concept would adapt graphically to other things, the idea is that this system works for any desired sprite in any situation, because in previous attempts I had to make really hacky stuff to accomplish a rather buggy look. Yes, maybe jumping would be cool to add but the main concept is that simple.

    I´ll try working around it if it´s too much to ask

  • This may help:

    https://dl.dropboxusercontent.com/u/542 ... hadow.capx

    This creates a shadow sprite for each object of the family.

    The shadow keeps track of the uid of the object it's paired with and how high it is, which i call "z".

    Then to move the objects I just move the shadow and put the objects's position to (shadow.x, shadow.y-shadow.z)

    For the jump I added another variable to shadow called "vz" which is just the vertical speed. Then I use the following to make it accelerate down due to gravity (400) but stop when z is 0. The result is a nice parabolic motion.

    every tick:

    add 400*dt to vz

    set z to max(0, self.z+self.vz*dt)

    Then to make it jump just set vz to -300 or something.

    You could change it up to move the shadow instead of the object. ( shadow.y=object.y+shadow.z )

    Just be sure to change the object's y when the z changes.

  • Oh, my, R0J0hound, can´t thank you enough. Works like a charm! I will be using this in many many occasions, thanks a LOT!

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