0 Favourites

Faking z heights

This forum is currently in read-only mode.
  • I have some objects set to a certain z height, how would I go about getting something like particles to show at that same x,y,and z?

    Is there a formula for doing that, or perhaps it should be done via another layer set to a different scroll rate?

  • Yeah, I'm pretty much screwed on that one I think.

  • There is a formula, but to do it properly is very complicated. Your best bet is to try and do everything with Z elevated sprites.

  • Well actually my current fix is to use just a separate layer, and no z heights for the sprites.

    The only thing I'm really missing is how the drop shadow object is effected. Its not really a big issue even because I can offset it to compensate somewhat. The size of the drop shadow is the only thing I cant change, but I could even fix that by making my own out of a sprite. Dunno perhaps the ability to change the drop shadows size should be requested.

  • EDIT: The following is assuming I understand your meaning correctly. Ignore otherwise .

    Emulating Z height is actually pretty easy. Only thing you need to know is the Z co-ordinate of the Camera, which is 100.

    CameraZ is the Camera Z Co-ordinate EmulatedZ is the Z height you wish to fake Object.Value is the value you wish to offset by the emulated Z height

    The basic formula is:

    Object.Value * CameraZ / (CameraZ - EmulatedZ) or

    Object.Value * 100 / (100 - EmulatedZ)

    For anything that does not involve the X/Y axis (Size, acceleration, speed, etc):

    Object.Value * 100 / (100 - EmulatedZ)

    Where Object.Value is the original value before any Z emulation.

    For Object.X its:

    ((Object.Value('X') - DisplayWidth*0.5) * 100 / (100 - EmulatedZ)) + DisplayWidth*0.5

    Where Object.Value('X') is Object.X before any Z emulation.

    For Object.Y its:

    ((Object.Value('Y') - DisplayHeight*0.5) * 100 / (100 - EmulatedZ)) + DisplayHeight*0.5

    Where Object.Value('Y') is Object.Y before any Z emulation.

    The DisplayWidth and Height parts are basically telling the Z emulation where the Camera's X and Y are focusing, so it can emulate accordingly. Remove them if you want to see what I mean, the Z will be focused at 0,0 rather than the center of your screen.

  • So...

    Always

    Particles set position to

    ((Sprite.X - DisplayWidth*0.5) * 100 / (100 - Sprite.ZElevation)) - DisplayWidth*0.5

    ((Sprite.Y - DisplayWidth*0.5) * 100 / (100 - Sprite.ZElevation)) - DisplayWidth*0.5

    Was kinda off. My particles initial x,y were way off the layout.

    I must be confusing something somewhere.

    [quote:1atz9zia]Where Object.Value('X') is Object.X before any Z emulation.

    Aren't they the same?

  • Yeah sorry about that, error on my part, should be:

    Always

    Particles set position to

    ((Sprite.X - DisplayWidth*0.5) * 100 / (100 - Sprite.ZElevation)) + DisplayWidth*0.5

    ((Sprite.Y - DisplayHeight*0.5) * 100 / (100 - Sprite.ZElevation)) + DisplayHeight*0.5

    By 'Where Object.Value('X') is Object.X before any Z emulation', what I'm really trying to say is don't do the following.

    Always

    Particles set position to

    ((Particles.X - DisplayWidth*0.5) * 100 / (100 - Particles.Value('Z'))) + DisplayWidth*0.5

    ((Particles.Y - DisplayHeight*0.5) * 100 / (100 - Particles.Value('Z'))) + DisplayHeight*0.5

    The 'Particles.X' would need to be what value X you want it to be pre-Z emulation, whereas here after a single tick it would be Z emulated, then Z emulated again, and again, exponentially, making it a complete mess. I hope that makes sense.

  • Thanks, that works better. Something is still a bit off tho, the particle object will start to leave the objects x,y after about 300 pixels.

  • I have some objects set to a certain z height, how would I go about getting something like particles to show at that same x,y,and z?

    Is there a formula for doing that, or perhaps it should be done via another layer set to a different scroll rate?

    well the easy way would be, create your own particle spawner. the math for scaling and movement to attach a non sprite to an object which is free in all dimensions is really complicated to tweak just right, and i don't really see the advantage of using a fake transformation of the particle object that'll look strange and out of place in your true 3d world. not to mention if youre setting the scroll and zoom settings for a layer to control one object, you wont be able to make any others ones, so youre stuck with one particle object. using sprites to make all your paritcles would allow

    -multiple spawning sources

    -its easier

    -your particles can travel through all dimensions instead of just one.

  • [quote:259roic0]well the easy way would be, create your own particle spawner. the math for scaling and movement to attach a non sprite to an object which is free in all dimensions is really complicated to tweak just right, and i don't really see the advantage of using a fake transformation of the particle object that'll look strange and out of place in your true 3d world. not to mention if youre setting the scroll and zoom settings for a layer to control one object, you wont be able to make any others ones, so youre stuck with one particle object. using sprites to make all your paritcles would allow

    -multiple spawning sources

    -its easier

    -your particles can travel through all dimensions instead of just one.

    I dont even want to think about how complicated a sprite emitter would be, plus I would think that would kill the frame rate at some point.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • Thanks, that works better. Something is still a bit off tho, the particle object will start to leave the objects x,y after about 300 pixels.

    trange, works perfect for me, are you using scrolling? Use the following if so:

    ((Sprite.X - (ScrollXLeft + DisplayWidth*0.5)) * 100/(100 - Sprite.ZElevation)) + (ScrollXLeft + DisplayWidth*0.5)

    ((Sprite.Y - (ScrollYTop + DisplayHeight*0.5)) * 100/(100 - Sprite.ZElevation)) + (ScrollYTop + DisplayHeight*0.5)

    Other than that, I'm not sure what the issue might be. Throw me your cap if you still have issues.

    EDIT: Let me know if you're going to need help with transforming the Size, Speed, Acceleration, etc, of the Particles. I might make a cap/tutorial to save you some time instead of this slow back and forth if so.

    EDIT2: Just noticed you were in chat, I'm in there for about the next 20 to 30 minutes if you need help directly.

  • Yeah that was it. Works like a charm.

    As to the size, all sprites will be set to the same z so thats no issue.

    Thanks!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Topic
19 2,670
Zaaephod's avatar
Zaaephod
Unread hot topic
0 Favourites
Faked Shadow Example (Updated)
26 3,055
DravenX's avatar
DravenX
Topic
0 Favourites
Fake 3D GTA engine
22 2,737
skymen's avatar
skymen