Jump to content


Photo

Only if Colliding


  • Please log in to reply
4 replies to this topic

#1 Kgamer14

Kgamer14

    GMC Member

  • GMC Member
  • 52 posts
  • Version:GM8

Posted 07 May 2012 - 12:57 PM

I need to know how i would check to see if the player is colliding with an object to set a variable to true. If he isn't colliding with the object, the variable is false. I can get him to make the variable true when he collides with the object, it's just when he moves away from the object the variable is still true. I need it to change to false when he moves away from it.

Thanks for the help
  • 0

#2 Jack Indie Box

Jack Indie Box

    GMC Member

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

Posted 07 May 2012 - 01:34 PM

either use one of the collision functions(circle, rectangle...) or use place_free, place_empty

but your better off using if(!place_meeting(x,y,obj_wall)){variable=0;}
i think that should do what you want
  • 0

#3 Kgamer14

Kgamer14

    GMC Member

  • GMC Member
  • 52 posts
  • Version:GM8

Posted 07 May 2012 - 01:51 PM

either use one of the collision functions(circle, rectangle...) or use place_free, place_empty

but your better off using if(!place_meeting(x,y,obj_wall)){variable=0;}
i think that should do what you want

Do i throw the code in the step event? I'm trying to use it, but the variable doesn't change back to 0 when it changes to 1.
  • 0

#4 element_boy6522

element_boy6522

    Your Awesome Friend

  • New Member
  • 418 posts

Posted 07 May 2012 - 01:56 PM

yeah, you would put it in step. You basically want it to say:

If i touch a wall -> set variable to x. If not -> set variable to y.

The step event makes it check if it touches a wall every time the game takes a "step" (default is 30 pr. second)

Edited by element_boy6522, 07 May 2012 - 01:57 PM.

  • 0

#5 Kgamer14

Kgamer14

    GMC Member

  • GMC Member
  • 52 posts
  • Version:GM8

Posted 07 May 2012 - 01:59 PM

yeah, you would put it in step. You basically want it to say:

If i touch a wall -> set variable to x. If not -> set variable to y.

The step event makes it check if it touches a wall every time the game takes a "step" (default is 30 pr. second)

Thanks for the help, it works now. I realized i needed an else command to fix the problem.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users