• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Windows GMS Studio 2 Code Error

A

Anhorakk

Guest
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
 

Attachments

TsukaYuriko

☄️
Forum Staff
Moderator
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.
 
A

Anhorakk

Guest
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.
 
A

Anhorakk

Guest
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!
 

TsukaYuriko

☄️
Forum Staff
Moderator
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.
 
A

Anhorakk

Guest
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 ^^'
 
A

Anhorakk

Guest
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.
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?
 

Toque

Member
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.
 
A

Anhorakk

Guest
Yea i tried, but i still don't understand what the error code is supposed to mean ^^'
 
E

Edwin

Guest
In fact, thread title says "GameMaker: Studio Studio 2 Code Error". :)
 

FrostyCat

Redemption Seeker
Yea i tried, but i still don't understand what the error code is supposed to mean ^^'
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) {
 
A

Anhorakk

Guest
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!
 
Top