GMS 2 Basic Collision

Discussion in 'Programming' started by SilverSurfer1221, Dec 22, 2016.

  1. SilverSurfer1221

    SilverSurfer1221 Member

    Joined:
    Sep 13, 2016
    Posts:
    78
    I am very, very new to GMS in general. I've completed the My First Game - Code Tutorial and now I am diving into DnD. I wanted to experiment a bit on my own so I can find my (massive) short comings and, thus, see what GMS2 concepts I need to nail down. Thus far, I had no issue getting my player instance to move about using the standard WASD keys. Yay, me!

    Now I've placed an instance from obj_wall with the intent of making the player instance stop moving when it collides with the wall instance. So far, I am failing at this simple task. Boo, me.

    With the player object (obj_player) selected and open in the work space, I go to Add Event and select Collision>obj_wall. But now I don't know what DnD object to drag into the Code area to cause the player instance to stop when a collision is detected between the wall and player.

    Any help here would be appreciated.

    As a side note: both spr_player and spr_wall have basic rectangular collision masks set with collision set to middle center. Also, I did drop in a Restart Room (when I couldn't get anything else to work) and that works. So, it appears GMS2 is detecting when the player instance collides with the wall instance. I just don't know what to drag into the code area to cause the player instance to just stop.

    Sorry for being so dense with this.
     
  2. SyntheticStorm9

    SyntheticStorm9 Member

    Joined:
    Oct 21, 2016
    Posts:
    98
  3. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,901
  4. SilverSurfer1221

    SilverSurfer1221 Member

    Joined:
    Sep 13, 2016
    Posts:
    78
    That's how it's done in GMS1, but there is no option to select the middle area for Set Direction Fixed in GMS2. In any case, this was the first thing I did (dropped in Set Direction Fixed) and selected nothing (thinking that would be the same as selecting the middle), but this does not stop the player instance from passing through the wall instance.
     
    SyntheticStorm9 likes this.
  5. SilverSurfer1221

    SilverSurfer1221 Member

    Joined:
    Sep 13, 2016
    Posts:
    78
  6. SilverSurfer1221

    SilverSurfer1221 Member

    Joined:
    Sep 13, 2016
    Posts:
    78
    This was (originally) posted in the GameMaker Studio 2 forum area because it concerns DnD in GMS2, not GMS1. I have this working in GMS1 quite fine and was trying to duplicate this in GMS2, which is where I am having the failure.
     
  7. SilverSurfer1221

    SilverSurfer1221 Member

    Joined:
    Sep 13, 2016
    Posts:
    78
    Here is a screen shot of the DnD code I have set up for this, if this will help.
     

    Attached Files:

  8. SyntheticStorm9

    SyntheticStorm9 Member

    Joined:
    Oct 21, 2016
    Posts:
    98
    Try making both objects solid.
     
  9. SilverSurfer1221

    SilverSurfer1221 Member

    Joined:
    Sep 13, 2016
    Posts:
    78
    Now I feel really stupid! That did it! It's just me trying to wrap my head around GMS2 DnD vs. GMS1 ... Thanks!
     
    SyntheticStorm9 likes this.
  10. csanyk

    csanyk Member

    Joined:
    Jun 20, 2016
    Posts:
    821
    @Mike will be along any minute to lambast the use of solid... :rolleyes:
     
    Conbeef likes this.
  11. Conbeef

    Conbeef Member

    Joined:
    Jun 21, 2016
    Posts:
    108
    lol yeah true. built in variable solid is a headache and could be ugly if there is a moving solid. Mike must have went through some pain with it xD
     
    SyntheticStorm9 likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice