• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

3D Weird error

Kentae

Member
Hey guys.

So I'm getting this really weird error and I just can't seem to find what's wrong.
Here's the error:
Code:
############################################################################################
FATAL ERROR in
action number 1
of  Step Event0
for object obj_terrain:

DoMul :: Execution Error
 at gml_Object_obj_terrain_Step_0 (line 12) -                      var x1 = ( c_x * ( chunkquads * quadsize ) ) + ( i * quadsize );
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_terrain_Step_0 (line 12)
And it happens when I run this code in the step event of my object:
Code:
// CHUNK GENERATION.
if ( c_x < chunks_x && c_y < chunks_y )
    {
    var vbuff = vertex_create_buffer();   
    
    vertex_begin( vbuff, global.format_default );
    
    for ( i = 0; i < chunkquads; i++; )
        {
        for ( j = 0; j < chunkquads; j++; )
            {
            var x1 = ( c_x * ( chunkquads * quadsize ) ) + ( i * quadsize );
            var y1 = ( c_y * ( chunkquads * quadsize ) ) + ( j * quadsize );
            var x2 = x1 + quadsize;
            var y2 = y1 + quadsize;
        
            var u1 = i / ( chunkquads + 1 );
            var v1 = j / ( chunkquads + 1 );
            var u2 = ( i + 1 ) / ( chunkquads + 1 );
            var v2 = ( j + 1 ) / ( chunkquads + 1 );
        
            vertex_position_3d( vbuff, x1, y1, 0 );
            vertex_normal( vbuff, 0, 0, 1 );
            vertex_color( vbuff, c_white, 1 );
            vertex_texcoord( vbuff, u1, v1 );
        
            vertex_position_3d( vbuff, x2, y1, 0 );
            vertex_normal( vbuff, 0, 0, 1 );
            vertex_color( vbuff, c_white, 1 );
            vertex_texcoord( vbuff, u2, v1 );
        
            vertex_position_3d( vbuff, x1, y2, 0 );
            vertex_normal( vbuff, 0, 0, 1 );
            vertex_color( vbuff, c_white, 1 );
            vertex_texcoord( vbuff, u1, v2 );
        
            vertex_position_3d( vbuff, x1, y2, 0 );
            vertex_normal( vbuff, 0, 0, 1 );
            vertex_color( vbuff, c_white, 1 );
            vertex_texcoord( vbuff, u1, v2 );
        
            vertex_position_3d( vbuff, x2, y1, 0 );
            vertex_normal( vbuff, 0, 0, 1 );
            vertex_color( vbuff, c_white, 1 );
            vertex_texcoord( vbuff, u2, v1 );
    
            vertex_position_3d( vbuff, x2, y2, 0 );
            vertex_normal( vbuff, 0, 0, 1 );
            vertex_color( vbuff, c_white, 1 );
            vertex_texcoord( vbuff, u2, v2 );
            }
        }

    vertex_end( vbuff );
    vertex_freeze( vbuff );
    }
The c_x and c_y variables are just counters that will go up to the same amount that the chunks_x and chunks_y variables are set to.
The chunkquads and quadsize variables are both set in the create event.

I'm trying to create a chunkbased terrain system but for testing purposes I'm just trying to make it as a flat plane for now.

What's weird is that it seems to have a problem with this sentance:
var x1 = ( c_x * ( chunkquads * quadsize ) ) + ( i * quadsize );
And I just don't get what's wrong with it. It doesn't seem to make any sense what so ever.

I'm using GMS2 for this and I'm quite new to it, I've usually stuck with GMS 1.4 so far but figured I'd try and make the switch now :) So I'm not discarding the possibilty that I'm just missing something trivial here hehe.
 
Can you show the code where you create / assign values to the variables in that line of code? ( c_x, chunkquads, quadsize)

One or more of those variables probably does not have a valid number assigned, hence the "DoMul" (Do Multiplication) error.

You could try putting a show_debug_message() for all those values and check the output window to see what their values are before that line of code.
 

Kentae

Member
Ahh, I found the problem. I was trying to get the c_x, c_y, chunkquads and quadsize variables from an inputfield system I made, that obviously doesn't work right.
Still weird it didn't throw me an error on that though.

Thanks IndianaBones :)
 
Top