Jump to content


Photo

Collision Code Causing Problem


  • Please log in to reply
1 reply to this topic

#1 bobhoil

bobhoil

    GMC Member

  • GMC Member
  • 1521 posts

Posted 23 May 2012 - 03:35 AM

So I think I have narrowed my problem down finally and I THINK it has to do with the collision code when my object becomes active and the terrain is created. Because when I create the terrain my ball object disappears and I am thinking it has to do with my collision code because when I delete the collision event the error does not occur.

o = ds_map_find_first(terrain_create.part);
oo = ds_map_find_next(terrain_create.part, o);
while(o != ds_map_find_last(terrain_create.part))
{
  if (ds_map_find_value(terrain_create.part, o).x <= x and ds_map_find_value(terrain_create.part, oo).x >= x)
  {
    break;
  }
  o = oo
  if(ds_map_find_last(terrain_create.part) != o)
  {
    oo = ds_map_find_next(terrain_create.part, oo);
  }
}
force_angle = arctan2(ds_map_find_value(terrain_create.part, oo).y-ds_map_find_value(terrain_create.part, o).y,ds_map_find_value(terrain_create.part, oo).x-ds_map_find_value(terrain_create.part, o).x);
ball_angle = arctan2(vspeed,hspeed);
force = mass*(vspeed*sin(ball_angle)+hspeed*cos(ball_angle));
new_angle = force_angle-3.14159/2;
vspeed += force*sin(new_angle);
hspeed += force*cos(new_angle);
if(abs(hspeed) > 2)
{
  effect_create_below(ef_smoke,x,y,.1,1000000);
}
if(y<other.y)
{
    while(instance_place(x,y,other.id) = other.id)
    {
        y+=.1;
    }
}
else if(y>other.y)
{
    while(instance_place(x,y,other.id) = other.id)
    {
        y-=.1;
    }
}

EDIT:
I have narrowed it down to the following bit of code:
if(y<other.y)
{
    while(instance_place(x,y,other.id) = other.id)
    {
        y+=.1;
    }
}
else if(y>other.y)
{
    while(instance_place(x,y,other.id) = other.id)
    {
        y-=.1;
    }
}
What do I need to adjust? I am not sure what the problem is.

Edited by bobhoil, 23 May 2012 - 03:37 AM.

  • 0

#2 bobhoil

bobhoil

    GMC Member

  • GMC Member
  • 1521 posts

Posted 23 May 2012 - 08:28 PM

It seems the ball appears at the top of the screen then starts to float down slightly before stopping. I think this has to do with the collision mask of the terrain being the size of the room? It isn't precise down to the actual "ground".
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users