Jump to content


Photo

I got an issue...


  • Please log in to reply
8 replies to this topic

#1 Quazarr

Quazarr

    Neon Ninja

  • GMC Member
  • 183 posts
  • Version:GM:Studio

Posted 12 March 2012 - 02:38 AM

Okay so basicly i have this thing where there is a gate and to destroy the gate you have to get the diamond. here is my code:

//the table in your house holds the variable "di"
//in create event for obj_table
global.di = 0

//collision with obj_player event for obj_diamond
//it just has a timeline so that after 1 second it destroys itself

//collision with obj_diamond for obj_player
global.di += 1

//collision with obj_player event for obj_gate
if global.di = 1{
instance_destroy()
}

my problem is the gate wont destroy itself

please help!

Edited by Quazarr, 12 March 2012 - 02:43 AM.

  • 0

#2 rude guss

rude guss

    GMC Member

  • GMC Member
  • 236 posts

Posted 12 March 2012 - 02:42 AM

Sorry buddy, I'd love to help but you haven't told us what the problem is, you've just given us code. GG

Edited by rude guss, 12 March 2012 - 02:42 AM.

  • 0

#3 Quazarr

Quazarr

    Neon Ninja

  • GMC Member
  • 183 posts
  • Version:GM:Studio

Posted 12 March 2012 - 02:42 AM

oh right sorry xD
  • 0

#4 Quazarr

Quazarr

    Neon Ninja

  • GMC Member
  • 183 posts
  • Version:GM:Studio

Posted 12 March 2012 - 02:44 AM

ok i edited my post
  • 0

#5 loverock125

loverock125

    GMC Member

  • GMC Member
  • 1706 posts
  • Version:GM8.1

Posted 12 March 2012 - 02:45 AM

try:

//collision with obj_diamond for obj_player
global.di = 1

My guess is that global.di gets increased above 1 before the collision event code takes place.
  • 0

#6 shinyjiggly

shinyjiggly

    a lame wanderer

  • GMC Member
  • 119 posts
  • Version:GM:Studio

Posted 12 March 2012 - 02:47 AM

Have you used debug mode to see what is happening with global.di?
  • 0

#7 Quazarr

Quazarr

    Neon Ninja

  • GMC Member
  • 183 posts
  • Version:GM:Studio

Posted 12 March 2012 - 02:48 AM

GG im so stupid it worked xD
  • 0

#8 Blake

Blake

    GMC Member

  • GMC Member
  • 443 posts
  • Version:GM:Studio

Posted 12 March 2012 - 02:51 AM

Okay, here's the deal. You say after the player collides with the diamond, it is destroyed after 1 second. If you have not altered the room speed and it is 30, that means that 30 steps will occur during that 1 second. Therefore, your code "global.di += 1" will be executed 30 times, which means global.di will end up equally 30. So then when you check to see if global.di = 1 and destroy the gate, it doesn't work because global.di is equal to 30, not 1!

Make sense? Now that I've explained what is causing the problem, why don't you have a go at solving it yourself? :thumbsup:

EDIT: Ahh, I take too long to write posts! :tongue:

Edited by Blake, 12 March 2012 - 02:52 AM.

  • 0

#9 Quazarr

Quazarr

    Neon Ninja

  • GMC Member
  • 183 posts
  • Version:GM:Studio

Posted 12 March 2012 - 02:57 AM

lol its ok xD
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users