Windows GMS Studio 2 Code Error

Discussion in 'Programming' started by Anhorakk, Mar 16, 2019.

Tags:
  1. Anhorakk

    Anhorakk Member

    Joined:
    Mar 16, 2019
    Posts:
    7
    Dear GMC,

    Hiya there! First of all let me introduce myself, my name is Mathis and i live in Canada. I am aged of 16 years old and i have recently been trying to learn 2D gave developpement with Game Maker Studio 2. However, recently, when i was making lines of codes, i tried to launch to see if everything was correct and i've gotten a unexpected error code coming out. I do not understand what is going on wrong.
    Thanks in advance for your generous help, i really appreciate it!

    Sincerely,

    Anhorakk
     

    Attached Files:

  2. TsukaYuriko

    TsukaYuriko Q&A Spawn Camper Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    1,051
    You did not declare the variable COLLISION. I'm not even sure if you're trying to use a variable there, so please tell us what you're trying to do at line 25.
     
  3. Anhorakk

    Anhorakk Member

    Joined:
    Mar 16, 2019
    Posts:
    7
    Hey, sorry i am still new in the domain, let me explain what i am trying to do. I am currently working on trying to make collision stuff. In other words i want to make a system that will make sort that if my character touches an object as an example, a wall, my character will just stop on the borders of the wall instead of passing through it.
     
  4. Anhorakk

    Anhorakk Member

    Joined:
    Mar 16, 2019
    Posts:
    7
    I don't know if this is clear enough, i am trying to explain, but first English is not my main language and i am still new in developing so yea, i might not be really clear. Let me know if you need more specifications!
     
  5. TsukaYuriko

    TsukaYuriko Q&A Spawn Camper Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    1,051
    Writing if (COLLISION) will not check for collisions.

    What you're looking for is a Collision event or functions like place_meeting. Both of them are covered extensively in the manual.
     
  6. Anhorakk

    Anhorakk Member

    Joined:
    Mar 16, 2019
    Posts:
    7
    Oh, sorry i have just realized i was talking of the wrong thing, my bad. But yea i also gotta set the collision checks, in this case what i meant to do is to set a thing that if a collision happens with a wall, the character will as an example move backwards from 1 frame. Sorry for the misunderstanding ^^'
     
  7. Anhorakk

    Anhorakk Member

    Joined:
    Mar 16, 2019
    Posts:
    7
    We might want to close this Thread, i've just realized i made a mistake in my explanation. I will remake my thread with the good informations?
     
  8. Toque

    Toque Member

    Joined:
    May 25, 2017
    Posts:
    736
    You might want to watch cosmonauts tutorials. Space rocks and brick breaker.

    It will help with collisions and probably answer this question and the next ten problems you run into.
     
  9. Anhorakk

    Anhorakk Member

    Joined:
    Mar 16, 2019
    Posts:
    7
    Yea i tried, but i still don't understand what the error code is supposed to mean ^^'
     
  10. Edwin

    Edwin Member

    Joined:
    Jul 15, 2018
    Posts:
    254
    In fact, thread title says "GameMaker: Studio Studio 2 Code Error". :)
     
  11. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    3,716
    The error message means what it says, and TsukaYuriko has already made herself clear. You didn't give COLLISION a value before trying to use it, and it's not a built-in variable. It's illegal in GML to reference a variable before having given it a starting value.

    On this line you are depending on the value of a variable named COLLISION:
    Code:
    if (COLLISION) {
    But at no point in time before this line runs did you set a value for COLLISION.

    This is an example of giving COLLISION a value first (though you're more likely to see the shorter form if (place_meeting(x, y, obj_wall) {):
    Code:
    var COLLISION = place_meeting(x, y, obj_wall);
    if (COLLISION) {
    
     
    Anhorakk and TsukaYuriko like this.
  12. Anhorakk

    Anhorakk Member

    Joined:
    Mar 16, 2019
    Posts:
    7
    Alright thank you very much! As i said in the comments, i am new to the domain so of course i do not understand everything when you speak with some specific terms. Also i am a French Canadian so yea, i won't understand all the terms but i understand most of them. On that note, i thank you very much for your help, and have a good time!
     

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