megatronx's Forum Posts

  • All you need is the camera position (cx,cy,cz), the fov, and the scroll position (scrollx, scrolly) apparently. Math below is adapted from the Wikipedia about 3d projection.

    screenx = (x-cx)/(z-cz)/tan(fov/2)+scrollx
    screeny = (y-cy)/(z-cz)/tan(fov/2)+scrolly

    There is no expression to get the fov so you’ll just have to remember it from when you set it.

    Not tested.

    What this is for? What could I do with it too?

    megamente Br

  • I can't help you with that. I only use x,y,z from 3d plugin, but I do camera rotation with my own system that works with c2 stuff and is understandable to me ( I yet to understand rotation vectors and how to use them )

    This is using Simple Mouse Lock plugin

  • megatronx

    I have no input on that other than yes you can access values in an array immediately after you set them.

    Maybe your logic just isn’t correct for what you’re doing. It could be helpful to output what’s going on at each step to debug things. Or maybe simplify the data you’re using to be able to analyze what’s it’s doing better.

    As is I can’t make sense of it. Arrays are useful but i find code using them often unreadable

    Thanks for reply. Ok. But here I'm only working with one number, dividing it and adding to another array cell, o this is as simple as can be. When I'm checking < in condition, the division by 10 in action doesn't divide by 10. Will investigate further then.

    EDIT. It's working today :> Now I'm literally few days away from completing the mesh gen stage :)

  • R0J0hound

    Can you help me out with something. Not plugin related but Idk if this is a bug or wtf?

    In the for loop y2 x2, both from -1 to 1, i'm doing this test between numbers in cells at x2,y2,2 . I'm taking number from a cell at 1,1,2 ( green ) and checking it against 4 other cells ( red ) inside 3x3x4 array. I only want to calculate cells that contain larger number then central cell and then divide them. This is super simple. It doesn't work thou! If the condition with > is there, it calculates something else, and still calculates those cells that have bigger number then central cell number. Please have a look at it and tell me is it me or it is a bug? Thx!

    Other than this, I manage to program working 3D bitwise mapping system, and this is a way I wanted to test where walls should go.

    Here's the whole loop. Conditions above are working. And I got to admit, I wanted to make one more bit calculation with condition checking same numbers for whole day today and couldn't get it to check properly, so decided on something else, and still this isn't working.

    EDIT Just realized that the first >= condition isn't working, and is passing trough. Really got to figure out is it a bug or not. Or maybe filling up array and checking it within the same for loop doesn't work?

  • > add n*( tSpace.At(1,1,0) = tSpace.At(x2+1,y2+1,0) )

    Sorry to be nosy, but are you trying to compare with a info inside the array is equal to another with a fórmula...

    And if it's: true - add the x value to array

    False: add value 0 to array

    ?

    It seems correct to me. Maybe you could try using the expression:

    {I put between parentheses to be easier to just copy and paste}

    * Remove que Comments I made...

    // Start Here (

    find(

    tSpace.At(1,1,0),

    tSpace.At(x2+1,y2+1,0)

    )

    <> //Not equal

    -1

    ) // End Here

    I think this expression might work.

    Thanks for help attempt but I've found where problems where made.

    Simply, I've made x and y in loops with wrong value, and then in another calculation I've had wrongly placed ().

  • R0J0hound I thought I'll let you know, If you will ever decide to do the 3D construct, I would like to help you out to the maximum of my abilities, that includes doc organisation, design, ui, some web stuff, and video and sound editing if you'd go for yt video like tutos ( I did a lot of official AOZ Studio tutorial videos ), and crowd founding.

    And a suggestion: it wouldn't even have to be an event based system, but having a language like Basic, which is pretty much what construct coding feels like, would be fully sufficient to make proper 3D indie games. Main thing would be renderer and that would have to be at a level of Manu at least.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • WOW!! Really?? I would love to see the project ROJO is working on... It will be similar to C2 engine? Or similar to Godot/Unity? I only knew about the existence of C2 three years ago during pandemy, also I only knew about ROJO I guess about 1 year ago...

    Seeing C2-like engines would be revolutionary!

    ROOJ said maybe he will do it. Nothing more.

  • megatronx

    Hey, do you know? Build each block from vertexes inside the game is there only way possible to 'disable' the invisible faces that are not being shown? maybe you had achieved this and I don't know...

    I don't think there is and they ae two sided.

  • Brooo.... I was searching for 3D Collisions and everything... I think it will be easier to learn how to program inside a 3D Engine, maybe it will be easier to learn all the Multiplayer mechanics for those 3D engines rather than learning how to implement a 3D Engine inside C2... Nah... (laughing desperately like the joker)

    You know, it's not a bad idea. There's godot with its scripting and manu, and maybe ROOJ will make his own software which I am looking forward too. When it comes to me, I know c2 very well and I want to make something in it before moving on.

  • > You probably need to limit the ray tests to a distance. for each rayAsset, distance < then, raycast.

    But if there is too much objects inside a layout?

    Like inside a Minecraft world there will be a radius of 4 blocks and almost everytime there is a block around the player...

    In other words: it will always be casting rays anyway.

    I mean, maybe I could test if what you said but instead ofy position, I test the position of the point in the ray near to the block... That would be equivalent to what I am doing to test if the point is overlapping a 3d cube.

    Depends what you are using. If you are using tilemap then you got to check tiles in front of the player within distance and if you are using sprite object you could use line of sight "is in sight" condition, and then test for ray cast.

    To calculate direction of casting depending on the players angle do something like this:

    ax= cos(player.angle) -distance, ay = -sin(player.angle) -distance

    Might not work straight away, you might need to change symbols from + to - for example to get correct direction, but if I recollect this is generally how you do it.

    And if you have sprite with line of sight then it will change the angle within the plugin itself automatically.

    But then you say it is like MC with loads of blocks. Max objects before NW.js starts slowing down is something like 40x40x2 ( this was my map x,y as well as objects for billboards above it , but more than that there will be a stutter, tested on i7-8750h as well as on 12700h! ).So you will need to nest arrays, and depending on player position access them, then arrays within them and place blocks accordingly. To do that each block has to have a boo that defines its availability. You will also need to keep track of which arrays been already used and which aren't. SO you could use second line of sight, larger and longer, and anything that is not in it will automatically have that flag set to off, and then from this pool you can pick as many as you have availed to fill up the terrain, while also keeping track of things in another array. This doesn't have to to work every frame thought, but every several ticks.

    Make yourself a tick clock. Have a global variable T and set it to (T+1)%6 for example, so this will give you numbers from 0 to 5, and then you can decide what happens when. Obviously action related stuff has to run every tick.

    This seams complicated but it isn't really, and you can have this system up and running within a day or two, just need to plan it out on page of a3 paper and you will know exactly what you are going to do.

    Also, lest say your cube is 10x10x10, then you can repeat the ray test n/10 times, so per grid and not per pixel.

  • Interesting, and thank you for the explanation I will try that, maybe It would be faster...

    ** About the raycast: I would be very interested too, soon I might upload here the template I made and it does have raycast, but it's laggy because it does too much collision checks per tick and it might not precise for very small positions also it only detect collisions for cubic meshes.

    You probably need to limit the ray tests to a distance. for each rayAsset, distance < then, raycast.

  • megatronx

    I didn't found the page about Rojo talking about it, was he talking about cubes or triangles? (the triangles one I found, but I was hoping to find the one talking about the cube already made by him...)

    Also, have you done raycasting in you project? Or won't it have it?

    Hi, I will be doing raycasting at some point. I will share it with you once done, but that's still some time away. Right now I'm still designing level building system.

    As for the box, simplest way i think is to create a sprite 10x10px, set 4 origin points and then at start of the level use them when creating vertexes. You will need to create a plane 6 times and each plane is 2 triangles, so 6 verts in total per plane. The UV order for each plane is 00 01 11 11 10 00. Example of creating a plane for side using image point sprites:

    ip1 ip2 This is how the sprites imagepoints are set

    ip4 ip3

    And this is creating a plane for wall using imagepoint1 and imagepoint2

    -create vert at X ImagepointX(1) Y ImagepointY(1) Z 0 UV 00

    -create vert at X ImagepointX(2) Y ImagepointY(2) Z 0 UV 01

    -create vert at X ImagepointX(2) Y ImagepointY(2) Z 10 UV 11

    -create vert at X ImagepointX(2) Y ImagepointY(2) Z 10 UV 11

    -create vert at X ImagepointX(1) Y ImagepointY(1) Z 10 UV 10

    -create vert at X ImagepointX(1) Y ImagepointY(1) Z 0 UV 00

    Without imagepoints you create plane just like this

    -create vert at X -1 Y -1 Z 0 UV 00

    -create vert at X -1 Y 1 Z 0 UV 01

    -create vert at X 1 Y 1 Z 1 UV 11

    -create vert at X 1 Y 1 Z 1 UV 11

    -create vert at X 1 Y -1 Z 1 UV 10

    -create vert at X -1 Y -1 Z 0 UV 00

    Then you'd need to scale it. Doing it this way will create origin point in the center of the plane.

    When you will be creating plane for top and bottom of the cube, you have to use all 4 image points and keep Z at 0, but wij sides you need to use only 2 image points and instead increase Z by a number. The order of vert creation can change, but the first and last, as well 2 middle ones must be in the same point. You can experiment.

    Once you create all planes, use save verts as mesh. Call the mesh and then create object and use that mesh. If you want different textures on each side, you got to have a texture with those sides and then set UV in such way that it is drawing only those tiles of the texture.

  • I still got no sucess, the origin point is centered at the 3rd program. It seems to lose this information when I import into C2...

    The object size at the 3rd program is (16, 16, 16)

    When, inside C2, I change to (64,64,64) the Z scale gets messed up and I will find myself 'flying' and the object will be bigger but not enough to fill the gap...

    When I try to change the Z origin to the bottom or top it it still to have the same problem when I change value... I'll try to change the 3rd program, but I don't it might be it...

    Or just create the box in c2 with vertices. One of ROOj examples have the code for the box.

  • R0J0hound

    I am having some issues with rendering, can you help me?

    The problem:

    - I have a mesh of a cube.obj (16, 16, 16) (X, Y, Z) (created using a 3rd program)

    - When I change Z to a higher number using events, I start to "fly", it's like with the object was pushed down by 8 pixels and there will be a gap between me and the object "floor".

    Do you what might be the problem?

    Probably an origin point problem. You have to place it more precisely in your 3d program.

  • MegaMente Br

    Here's the tuto code.tutsplus.com/how-to-use-tile-bitmasking-to-auto-tile-your-level-layouts--cms-25673t

    I've implemented 8directional version.

    This is the code to put in to BIT variable I'm using for my project, but you will have to customise it cause I'm using variables. It checks if the tile at xy is same as the current tile, and if so it ads a number.

    varTileType = (Tilemap.TileAt(x, y)

    ((Tilemap.TileAt(x+1, y) = TileType)*16) +( (Tilemap.TileAt(x, y +1) = TileType)*64 )+ ((Tilemap.TileAt(x-1,y ) = TileType)*8 )+ ( (Tilemap.TileAt(x,y -1) = TileType)*2) + ( (Tilemap.TileAt(x+1, y+1) = TileType)*128 * ((Tilemap.TileAt(x+1, y) = TileType)) *((Tilemap.TileAt(x, y+1) = TileType)) )+( (Tilemap.TileAt(x-1, y +1) = TileType)*32 *((Tilemap.TileAt(x,y+1) = TileType)) *((Tilemap.TileAt(x-1, y) = TileType)) )+( (Tilemap.TileAt(x-1, y -1) = TileType)*1*((Tilemap.TileAt(x-1, y) = TileType))*((Tilemap.TileAt(x, y-1) = TileType)) ) + ( (Tilemap.TileAt(x+1,y-1) = TileType)*4*((Tilemap.TileAt(x, y-1) = TileType)) *((Tilemap.TileAt(x+1, y) = TileType)) )

    Then you need to create array with 256 cells. Each cell coresponding to the table below should have a tile number.

    ( first number is the array cell column and second number is the tile number )

    { 2 = 1, 8 = 2, 10 = 3, 11 = 4, 16 = 5, 18 = 6, 22 = 7, 24 = 8, 26 = 9, 27 = 10, 30 = 11, 31 = 12, 64 = 13, 66 = 14, 72 = 15, 74 = 16, 75 = 17, 80 = 18, 82 = 19, 86 = 20, 88 = 21, 90 = 22, 91 = 23, 94 = 24, 95 = 25, 104 = 26, 106 = 27, 107 = 28, 120 = 29, 122 = 30, 123 = 31, 126 = 32, 127 = 33, 208 = 34, 210 = 35, 214 = 36, 216 = 37, 218 = 38, 219 = 39, 222 = 40, 223 = 41, 248 = 42, 250 = 43, 251 = 44, 254 = 45, 255 = 46, 0 = 47 }

    Then all you have to do is to have appropriately placed tiles on the tilemap's tileset.