Jump to content


Photo

Collision Line Problem


  • Please log in to reply
12 replies to this topic

#1 lmzanchi

lmzanchi

    GMC Member

  • New Member
  • 68 posts

Posted 22 June 2007 - 02:56 AM

I have three different objects. obj_character, obj_red, and obj_scanner. Obj_scanner has this in its code for the step event:

collision_line(x,y,x+room_width-x,y+room_height-y,obj_character,0,0)
global.deadscanner=1

I want it to check and see if obj red is in the way of the character.  :D
  • 0

#2 PhantomPossessed

PhantomPossessed

    GMC Member

  • New Member
  • 412 posts

Posted 22 June 2007 - 02:59 AM

That has issues, try this... Your original script is saying to check if obj_character is in the way.

collision_line(x,y,x+room_width-x,y+room_height-y,obj_red,false,true)

that checks if obj_red is in the way

Edited by PhantomPossessed, 22 June 2007 - 02:59 AM.

  • 0

#3 lmzanchi

lmzanchi

    GMC Member

  • New Member
  • 68 posts

Posted 22 June 2007 - 03:03 AM

hmm. I didnt work. I think the problem is that it checks for red, but not if red is in way of character. Also, how would i mkae it where it sets the var to 1 if character is not behind red?
  • 0

#4 PhantomPossessed

PhantomPossessed

    GMC Member

  • New Member
  • 412 posts

Posted 22 June 2007 - 03:09 AM

thats confusing, could u post your entire script?
  • 0

#5 lmzanchi

lmzanchi

    GMC Member

  • New Member
  • 68 posts

Posted 22 June 2007 - 03:11 AM

in obj_character in step:
if global.deadscanner=1 then
{
instance_create(x,y,obj_playerdie3)
instance_destroy()
}
in obj_scanner step:
if collision_line(x,y,x+room_width-x,y+room_height-y,obj_red,false,true)then
{
global.deadscanner=1
}
else
{
global.deadscanner=0
}
obj_red is just the block(itsa platform game)
  • 0

#6 PhantomPossessed

PhantomPossessed

    GMC Member

  • New Member
  • 412 posts

Posted 22 June 2007 - 03:15 AM

Essentially ure saying that if obj_red is touching the character then kill the character? Or am i wrong?
  • 0

#7 bluemagica

bluemagica

    Grand Wizard

  • New Member
  • 3243 posts

Posted 22 June 2007 - 03:16 AM

x+room_width-x,y+room_height-y <------thats the problem i guess
try
x+(room_width-x),y+(room_height-y)
  • 0

#8 lmzanchi

lmzanchi

    GMC Member

  • New Member
  • 68 posts

Posted 22 June 2007 - 03:18 AM

Obj_red is the block that obj_character jumps on like a platform game. It is like a wall and if obj_red is inbetween scanner and character character is alive.If the scanner can clearly 'see' the character(obj_red is NOT inbetween the two) character dies. :D
  • 0

#9 PhantomPossessed

PhantomPossessed

    GMC Member

  • New Member
  • 412 posts

Posted 22 June 2007 - 03:21 AM

Oh, i see,

if global.deadscanner=1 then
{
instance_create(x,y,obj_playerdie3)
instance_destroy()
}
in obj_scanner step:
if collision_line(x,y,obj_character.x,obj_character.y
,obj_red,false,true)then
{
global.deadscanner=1
}
else
{
global.deadscanner=0
}

now it says that if there is not a block between the two, then the character dies

Edited by PhantomPossessed, 22 June 2007 - 03:22 AM.

  • 0

#10 bluemagica

bluemagica

    Grand Wizard

  • New Member
  • 3243 posts

Posted 22 June 2007 - 03:22 AM

in obj_scanner step:
if collision_line(x,y,obj_character.x,obj_character.y
,obj_red,false,true)then
{
global.deadscanner=1
}
else
{
global.deadscanner=0
}
o
  • 0

#11 lmzanchi

lmzanchi

    GMC Member

  • New Member
  • 68 posts

Posted 22 June 2007 - 03:24 AM

Now it sasys in an error box: unknonw variable x and unkonwn varibale y!!! ?!?!


Can someone help? i have no idea why its doin that

Edited by lmzanchi, 22 June 2007 - 03:42 AM.

  • 0

#12 bluemagica

bluemagica

    Grand Wizard

  • New Member
  • 3243 posts

Posted 22 June 2007 - 04:04 AM

hmmph make sure you have a obj called obj_character before referencing it, and post the exact error message or show the screenshot of it. Also update on how youi have changed the code.
  • 0

#13 icuurd12b42

icuurd12b42

    Self Formed Sentient

  • Global Moderators
  • 14395 posts
  • Version:GM:Studio

Posted 22 June 2007 - 08:34 AM

if(collision_line(obj_character.x,
obj_character.y,
obj_character.x+lengthdir_x(room_width,obj_charact
er.direction),
obj_character.y+lengthdir_y(room_width,obj_charact
er.direction),
obj_red,true,true)>0)
{
// obj_red is in the way of obj_character...
}
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users