rustomatic's Forum Posts

  • The 3D Fog (exponential) effect must be depth-based (i.e. a plane perpendicular to the camera direction) because, especially at wider FOVs, you can get very unnatural looking drop-off of the fog at the edges of your view due to it not curving around.

    Is there any way of adjusting the effect to be distance-based instead to avoid this issue? Or has someone, by any chance, already created a modified version of the effect that does this?

    Tagged:

  • So I solved this issue and, in case it helps anyone else, the answer is to work out which of the two triangles your point of interest is in and then interpolate using the three mesh points of that triangle. Points on the diagonal line are essentially in both triangles so it doesn't matter which one you use to solve those.

    What I was trying to do previously didn't work because the two triangles are two different planes so you can't interpolate using the four values all at once as that only works for single planes.

  • Hi

    I have been playing with using meshes to create uneven ground for a 3D game. So a tiled background has a mesh set on it and then the Z elevation of each mesh point is randomised.

    I then obviously want the player and NPCs to adjust their Z elevation depending on where they are on the mesh.

    So I thought that Bilinear Interpolation would be the solution, however I'm finding there are a number of cases where it falls down. Namely when there is a diagonal 'fold line', either a 'ridge' or 'valley', across that section of the mesh.

    Here is an example of what I mean. The numbers represent the Z elevation of each of the surrounding 4 mesh points. The dotted line is a 'ridge' that passes diagonally across this section of the mesh.

    If I want to find the Z elevation of the centre of this section of the mesh Bilinear Interpolation will return the value 1.5 but the correct answer is clearly 2.

    I also gave Cubic Interpolation a try (though I'm not completely sure I'm doing it right) and that returned 1.75. Better but still not correct.

    Open to any assistance or suggestions of how to do this correctly.

    Thanks!

  • Thanks, though ideally I'd like to achieve this without 3rd party plugins.

    Is there any other way?

    The more I think about this issue the more it seems to be a bit of a fundamental thing to be missing. It would make complete sense if the 3D camera couldn't rotate around two axes. But it can and it just seems sensible to me that 3D Shapes should have the same rotation abilities as the 3D Camera...

  • Hi

    I've been testing various aspects of the 3D features to see whether it's possible to make something akin to a Build engine game in Construct. So far everything works fine except for how projectiles are displayed.

    Let says I have a circle Sprite that represents the projectile which is displayed on a 3D Shape billboard. If I fire that at a polar angle of 90 degrees, no problem. However if I then look up and fire at say 30 degrees, the circle Sprite appears distorted because it is no longer directly facing the camera. The camera is viewing it at an angle, not straight on.

    I'm aware you can't currently rotate a 3D Shape along the polar (Y?) axis. Is this functionality that could be added in the near future? If not, is there a workaround to somehow alter the Sprite itself? And, if so, does anyone happen to have a simple example of it for a projectile?

    Cheers

    Tagged:

  • Solved this.

    In case anyone else has the same issue the answer is... I hadn't put the 3D Shape and Sprite into a Container together *face palm*

    Now everything works fine.

  • Hi

    In the 8-sided Billboard example if you drop in multiple billboards the Face Object Sprite seems to be being individually set per 3D Shape (because they can be showing different animations).

    I cannot for the life of me replicate this in my own project.

    I have code that correctly stores into an instance variable of each 3D Shape the required animation name for the Face Object Sprite.

    However when I loop through the 3D Shapes and set the animation of the Sprite being used as the Face Object the action just sets all the Face Objects every iteration so they all end looking the same as the last 3D Shape in the loop.

    What am I missing here?

  • You do not have permission to view this post

  • Whoops, entirely forgot about this thread. Thanks for the pointers guys.

    In case anyone cares, in the end I scrapped looping through an array and instead used picking to essentially do the same thing which works a lot better.

    I've also realised I inadvertently didn't tell the whole truth in the initial post as while the trees were static in the sense that they stayed in the same place they were actually made up of 4 sprites, the top three of which were being moved around relative to the player (for a pseudo 3D effect). Therefore thousands of them doing this when they couldn't even be seen by the player was super inefficient.

  • Hello everyone

    So I'm working on a game where there is a forest.

    I have a (currently 80x80) array that stores whether there is a tree or not in each cell. Trees are static, solid objects.

    Originally I had the whole forest be built at the start of the game but I noticed in the inspector that CPU usage was very high, presumably because of the amount of objects (approx. 2000). However I was able to maintain a pretty consistent 60fps on my older machine with no obvious stuttering.

    However I ideally wanted the forest to be bigger and that became very problematic performance-wise. So I thought I'd be clever (uh oh) and have the trees 'stream' in from the array only when the player was near to them.

    My initial crude go at this was:

    Every 0.5 seconds --- Destroy all Trees

    --- For each XY Element in Array

    ------ If CurValue is 'tree' and distance from CurX,CurY to player X,Y < 400 --- Create object Tree at that location

    Now in the inspector the CPU usage is so much better however the framerate is worse. There is now a noticeable stutter every time this loop runs, i.e. every half a second.

    I've deleted parts of this to check and it appears to be nothing to do with the destruction and creation of the trees and purely related to looping through the array.

    Is there a better way to do this loop? Or even a better approach than arrays in this instance?

  • Ah yes, I should have specified that the collision polygon does matter.

    I did wonder whether there was some way of pinning two physics objects together to achieve this. I'll have a play around with your suggestion, thanks.

  • Ah, okay! I do recall reading that bit in the manual but I (incorrectly) assumed it was specific to joints. It doesn't make a lot of sense to me having 0 specify the centre of mass/gravity and -1 specify the origin when the origin is image point 0 but there we go! I think I may have actually tried -1 previously hoping that might specify centre of gravity and obviously didn't get the desired result. Thanks!

    Modifying my original question for a moment and making the shape say a rectangle of 4x3 px, is there some way to apply a force to the centre of mass for one dimension but not the other? So, applying a force to 1, 1.5 px for example.

  • Thanks for your response 99Instances2Go.

    So I now see from your capx how to find the centre of mass of an odd pixel-sized object. However I'm still unsure how this translates into applying a force to that point?

    Unless I'm missing something, the apply force dialogue box implies you can only set the position of application to the origin or an image point.

  • Try Construct 3

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

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

    Is it possible to apply a Physics Force to the exact centre of a Sprite if the Sprite is an odd number of pixels high/wide?

    So, for example, let's say I have a 3x3 square. Is there some way to apply a single force to the centre of the object?

    It appears that while collision polygon points can be assigned to half pixel positions, origins and image points cannot so there seems to be no way to apply a force to the centre...

  • Couldn't sleep so had another look and I may have solved my issue. Not sure how other people have implemented this sort of thing but this seems to work so far. Posting in case it's useful to anyone else and also in case there's something terribly wrong with this methodology so I can be corrected!

    On start of layout--------------------Set HorizScale to floor(browser.ScreenWidth/480)

    ----------------------------------------------Set VertScale to floor(browser.ScreenHeight/320)

    ----------------------------------------------Set canvas size to browser.ScreenWidth x browser.ScreenHeight

    ||||---------HorizScale < VertScale-----Set layout scale to HorizScale

    ||||---------Else-------------------------------Set layout scale to VertScale

    ||||----------------------------------------------Scroll to (342,192)

    So what this does is at the start of layout it determines the scale of the device's horizontal and vertical resolution relative to the safe zone resolution (in this case 480 x 320) rounded down. It then sets the canvas size to the device's resolution so the game fills the screen. It then determines which scale factor is smaller and scales the layout to that one. Finally it scrolls to the centre of the layout (in this case 342,192 as the layout is 684 x 384).

    This seems to work provided 'Fullscreen in browser' in Project Properties is set to anything other than 'Off'. I'm not sure whether there's a particular choice other than that which is best...