• Hey! Guest! The 39th GMC Jam will take place between November 26th, 12:00 UTC and November 30th, 12:00 UTC. Why not join in! Click here to find out more!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

SOLVED Hi. I'm getting the error of too few vertices in polygon shape fixture for...4 objects!

SlFinn

Member
Hi. I am trying to use physics in my space shooter game . When i click play it compiles but comes up with this error for two space ships and my laser objects:

ERROR in
action number 1
of Create Event
for (object here):

Too few vertices in polygon shape fixture for(object here)
I have actually looked on YoYo Games website for Physics in Game Maker but i don't understand how to fix this error. If anyone could help me or explain to me what is wrong and how to fix it,
i would appreciate it soooo much!
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Moderator
Make sure the Object doesn't have the "uses physics" checkbox ticked in the object editor.
 

FrostyCat

Member
Also, don't turn on physics in your project just because things are moving.
Just because things are moving, it doesn't mean you should use the physics system for it. Using the physics system implies a complete simulation of all linear and rotational dynamics, e.g. conservation of momentum, centre of gravity, action-reaction, etc. Examples of projects that should use the physics system include pool, pinball or the Angry Birds series. Anything not like these should be considered cartoon physics and have its movement handled manually.
 

FrostyCat

Member
ok thank you. I thought i had to use physics to be able to use collisions. My lasers are not destroying the asteroids like they should. The asteroids seem to be floating on top of my space ships and lasers. So i thought physics was the answer. But perhaps it is something to do with layers instead?
Do the Space Rocks tutorial from the Learn page. It will tell you how to handle collisions properly in a setup without physics.

Also, nobody can tell you what's wrong with your code unless you post it. But it probably has nothing to do with layers.
 

SlFinn

Member
i have been following that tutorial :) i have copied the same code but the lasers aren't destroying the asteroids. I am trying to figure out how to fix it though...
 

SlFinn

Member
Here is my code for the obj_asteroid and the lasers....please help if you can.

obj_asteroid Create Event:

GML:
sprite_index = choose(spr_asteroid_small, spr_asteroid_med);

direction = irandom_range(0,359);
image_angle =irandom_range(0,359);

speed = 2;
obj_asteroid Step Event:

Code:
y+=speed;

image_angle += 1;

move_wrap(true,true,sprite_width/2);
obj_allyship; asteroid collision event:

Code:
instance_destroy();

repeat(7) {
    instance_create_layer(x, y, "Instances", obj_debris);
}
obj_player; asteroid collision event:

Code:
instance_destroy();

repeat(7) {
    instance_create_layer(x, y, "Instances", obj_debris);
}
obj_laserbullet; asteroid collision event:

Code:
instance_destroy();

with(other) {
    instance_destroy();
    
    if(sprite_index == spr_asteroid_med) {
        repeat(2) {
            var new_asteroid = instance_create_layer(x, y, "Instances", obj_asteroid);
            new_asteroid.sprite_index = spr_asteroid_small
        }
    }
    else if(sprite_index == spr_asteroid_small) {
        repeat(7) {
    instance_create_layer(x, y, "Instances", obj_debris);
    
        }
    }
    
}
obj_allybullet; asteroid collision event:

Code:
instance_destroy();

with(other) {
    instance_destroy();
    
    if(sprite_index == spr_asteroid_med) {
        repeat(2) {
            var new_asteroid = instance_create_layer(x, y, "Instances", obj_asteroid);
            new_asteroid.sprite_index = spr_asteroid_small
        }
    }
    else if(sprite_index == spr_asteroid_small) {
        repeat(7) {
    instance_create_layer(x, y, "Instances", obj_debris);
    
        }
    }
}
obj_debris Create Event:

Code:
direction = irandom_range(0,356);
speed = 0.7;
obj_debris Step Event:

Code:
image_alpha -= 0.01;
if(image_alpha <= 0) {
    instance_destroy();
}
Please help me figure out the reason why the asteroids are not being destroyed by the lasers, why there is no collision. I will really appreciate it.
 

Tornado

Member
The first thing you have to check is if collision event between those two objects is triggered at all.

I don't have time to study the code in detail, but you can always help yourself by using
show_debug_message(...);
or by setting breakpoints in the code and using the debugger.

That way you'll immediately see if the event is triggered or not and then investigate further.
 
Top