!!SCRIPTS HAVE CHANGED IN VERSION 2.3!! Rather than being custom functions, scripts now simply contain functions (and can contain multiple!) so they must now be declared by using the "function" statement This will be obvious upon making a new script, the declaration code you need will be created for you. Instead of calling the script itself, you now call the functions within them! Here's an explanation from YoYo: help.yoyogames.com/hc/en-us/articles/360005277377
@andreseungyeobsong48994 жыл бұрын
Thanks for the update!
@dopamine73444 жыл бұрын
so what do we need to do to fix it D: very new to gamemaker lol
@SaraSpalding4 жыл бұрын
@@dopamine7344 Use the same code but wrap them in a function definition, for example: function Approach() { (code goes here) }
@dopamine73444 жыл бұрын
@@SaraSpalding oh thank you! I 100% overthought it and figured you had to do a lot more, thanks dude c:
@apollolane88793 жыл бұрын
i know Im asking the wrong place but does anyone know a trick to get back into an instagram account?? I somehow forgot the account password. I love any tricks you can give me
@Tezla_Insanity7 жыл бұрын
Odd moment when your watching a tutorial for Gamemaker and a Unity advertisement appears.
@kahztein13977 жыл бұрын
One thing I always found to be really useful is having a script that simply returns a certain amount of seconds. So just: return ceil(argument0*room_speed); And then writing s(1) for one second, s(0.5) for half a second etc. I just find it to be a lot more intuitive to write most of my time based code and whatnot as seconds instead of ticks. You can even use it for setting movement speed per second or slowing down/speeding up time (by using a global variable instead of room_speed). The ceil part is just a personal preference so I know I've got a whole number (and it's not zero)
@EnzuccioGameplays7 жыл бұрын
That's cool and I never thought to make it as a script. Thanks a lot man. Just to add more info about, it's important to not mistake the definition of time itself with the one dependent on the frame progression. Since the framerate is unstable, the higher the value in seconds you put in the script, the worst is the error obtained in time lag. I understood that when I dealt with a rhythm game and I needed a perfect sync. In those case, It's best to work directly with real time timers
@kolegaramic2607 жыл бұрын
Make this a series, you can make shaders top 5 like this
@Jorvanius6 жыл бұрын
Oh, man, that's the one.
@adamprokop5 жыл бұрын
@@Jorvanius I agree!!
@zedkhov7 жыл бұрын
Thanks for posting these Shaun. Already making use of a couple of them in a prototype. Saved me a decent amount of time :)
@SyntekkTeam7 жыл бұрын
I usually make a print function. it works just like show_debug_message except it's easier to type and you can write things like print("x: ",5) without having to do any casting :)
@anintendofankindaguy13687 жыл бұрын
Scripts, they save sanity.
@sparkyspartan51127 жыл бұрын
oh my, I needed the wrap() script badly for the longest time! Super useful video
@St3fa9s9 ай бұрын
Great tutorial! I used to reuse my chunks of code very often by copying and pasting them, which made my code very hard to read, thanks for explaining this, I'll definitely use scripts in the future :)
@didjargo7 жыл бұрын
The most helpful thing I learned in this video was the whole @discription and @param thing for the custom scripts. Beforehand, I would frequently need to open up the window for my script when I want to use it because I cannot remember what arguments do what. Now I don't have to, thanks for that.
@GoldScale577 жыл бұрын
This is a script I use a lot. Mostly for Jumping and Dashing. I think it's kinda simple math but it helps if you forget even simple formulas a lot like I do. ///Set_Dist_Vel(deceleration, distance); var decel = abs( argument0 ); var dist = argument1; return sign( dist ) * ( sqrt( decel * 2 * abs( dist ) ) ); //or just use return sqrt( decel * 2 * abs( dist ) ) //I tend to be overly cautious with my math Example: jump_speed = Set_Dist_Vel(gravity_value, -16*3) This helps makes sure that the character jumps the same height (-48 pixels) no matter what their "gravity_value" is.
@anonymous18084 жыл бұрын
Oh? You're Approach()ing me?
@St3fa9s9 ай бұрын
If (you're approach()ing) run(away); }
@DragoniteSpam7 жыл бұрын
A few "library" scripts that I use in pretty much every project - - a bunch of *array* functions that GMS1 didn't have - *instanceof* : returns whether an instance is descended from (or is, itself) an object type - *is_clamed* : Sort of an inverse to _clamp()_ - *null* : Takes any arbitrary number of arguments, does nothing, returns zero. Used often in tandem with _script_execute()_ - *print* : Saves typing from _show_debug_message()_ - *scaleTo* : scales a value from one maximum to another
@DJaycerOfficial6 ай бұрын
I personally created a function called loop_menu() which kinda works like clamp but instead of stopping the value at the max, it’ll go back to the beginning when attempting to go down again in the menu. I also used it in my battle system for making sure the turn variable never goes over the length of units variable.
@benedictnothing7 жыл бұрын
Cheers for these tutorials, matey. You're a proper legend.
@sabriath4 жыл бұрын
Wrap: if(_val < _min) return _max-(_min-_val)%(_max-_min); else return _min+(_val-_min)%(_max-_min); Not entirely sure why you were +1 everywhere in the script, but whatever, the above script uses no loops and solves in one go
@IceMetalPunk6 жыл бұрын
The Wrap script could also be turned into two lines... while (argument0 < argument1) { argument0 += argument2; } return argument0 % argument2;
@amazingsparckman7 жыл бұрын
whoa cool scripts le Shaun! I am be tryin' this later on.
@MarioVelezBThinkin7 жыл бұрын
That wrap one helps a lot.
@TJCorporation7 жыл бұрын
Can you post a link to copy and paste these scripts?
@Aresous7 жыл бұрын
yeah fr, very tedious having to type the whole thing.
@Aresous7 жыл бұрын
thanks mate
@EnzuccioGameplays7 жыл бұрын
Thanks a lot. Very helpful, as always ^^
@Axolotine7 жыл бұрын
puu.sh/wWGNv/835d4d702a.zip (a zip file with all the code in the vid cleaned up and with more documentation)
@Aresous7 жыл бұрын
axolotine, appreciate the effort homie.
@DiamondWolfX7 жыл бұрын
I recently made a simple script called xyg. It sets the hspeed, vspeed, and gravity (or any related variables you use). I use it in things like fireballs, but it can be used for quite a few things.
@WangleLine5 жыл бұрын
These are super useful, thanks!
@illdie3147 жыл бұрын
A script for movement that is the same independent of framerate (I didn't come up with a name whatever): scr( val, fps) var dt = delta_time/1000000; return argument0*argument1*dt;
@DINGOS307 жыл бұрын
wow this was a great code reference video I'm keeping this one thnx Shaun!😉
@mushroomdude1237 жыл бұрын
I've been struggling to make a bird enemy in my game, that wave script is perfect for that!
@joshuacahill21397 жыл бұрын
Loved wave and the idea for wrap. But I have a few questions. 1. Why does wrap look so complicated? While loops? Here is what I got, I use mod just in case the value was adjusted that much: [serious edit - I revisited wrap, last was cleaner but this is even more so] var curv = argument[0], minv = argument[1], maxv = argument[2]; var delta = maxv - minv; var result = (curv - minv) % delta; if result
@IceMetalPunk6 жыл бұрын
The approach script could be made much, much shorter: return argument0 + sign(argument1 - argument0) * min(argument2, abs(argument1 - argument0))
@Diegovz01 Жыл бұрын
I'm checking the wave function because I'm making some moving platforms but I'm struggling to figure out what does the offset argument does?
@NickoTyn7 жыл бұрын
But I like your voice on the internet. Keep up the good work.
@kanolem Жыл бұрын
hello, if it's possible. Can you make an updated version for this useful scripts.
@guycomments7 жыл бұрын
you should make more videos featuring more small quality of life type scripts like these
@Eddygeek185 жыл бұрын
they seem useful in certain scenarios, but i wouldnt use them enough to waste time at the start of each project typing them all in. plus with all of them i didn't feel they saved that much extra time than just writing the code in
@lionjeff16403 жыл бұрын
You can copy assets from one project to another. Now with the 2.3 functions, I think you can store all useful ones into a single script and import in a new project? Just FYI, hope it helps!
@Rocky-ir1bc5 жыл бұрын
the wave script is just... perfect...
@myleskerwin25 жыл бұрын
The wrap joke was the best!
@gms23787 жыл бұрын
I must be sincere, before GMS2 I wasn't following you... but those videos are great so, good job Shaun!
@foof73525 жыл бұрын
The scripts are really nice to organize and make code more readable, but is there any efficiency downside to using this a lot? In terms of replacing code with scripts for things that aren't going to be universally used.
@slaz87617 жыл бұрын
Very helpful videos, just like the others XD
@ShmargleFoil7 жыл бұрын
Here's a much simpler wrap script I came up with a while ago. ///wrap(val, min, max) var val = argument0; var minimum = argument1; var maximum = argument2; var range = maximum - minimum; while(val >= maximum) val -= range; while(val < minimum) val += range; return val;
@igorthelight7 жыл бұрын
Here is my version of this script. It must be a little bit faster: /// @desription Wrap)value, minimum, maximum) /// @param value /// @param minimum /// @param maximum var range = argument2 - argument1; while(argument0 >= argument2) argument0 -= range; while(argument0 < argument1) argument0 += range; return argument0;
@victorstk6 жыл бұрын
Having the same issue as Matt Kemp with the Wave Script "Having an issue with the Wave script. Any object I code to move via the script ( y = wave(y+3, y-3, 2, 0 ) or any variation of that )seems to never properly reset upon room, or game restart."
@jinwookim91284 жыл бұрын
You are god of GMS2 Thank you for your video.
@cube_cup7 жыл бұрын
It says Wave() when you explain Approach()
@LuigiXHero7 жыл бұрын
oh I programmed my own warp script before but it was a lot more bare bones and it worked but this warp seems a lot better.
@ZacDevDude5 жыл бұрын
Absolutely want more videos like this! Love the Approach script.
@SuperBucketbot7 жыл бұрын
Having an issue with the Wave script. Any object I code to move via the script ( y = wave(y+3, y-3, 2, 0 ) or any variation of that )seems to never properly reset upon room, or game restart. This results in enemies/bosses having differing positions than I'd like. For example a boss I've made will sometimes fly up and down normally, sometimes much lower, spending 50% of its time in the floor, or vice versa with the ceiling The movement is constant, and perfectly balanced. The only issue is where the movement begins I think. Any advice?
@SuperBucketbot7 жыл бұрын
Thank you very much Shaun. I assumed everything would reset upon room/game restart. When it wasn't, I thought I should mess with the Create Event or something, but to no effect. This has solved my issue completely though, I appreciate it a lot. Keep making quality content my friend. :)
@icouch57816 жыл бұрын
Sorry to bother, but what was the solution? I guess Shaun deleted his reply.
@victorstk6 жыл бұрын
i want to see the solution also please
@peppermintgal43026 жыл бұрын
@@icouch5781 Probably something like having a timing variable to base the wave on, rather than using the time the game has been running for?
@BluecoreG7 жыл бұрын
Wouldn't it be better to use if (70 > irandom (100))
@einsfuffzich7 жыл бұрын
Since irandom always returns an integer, irandom(1) will return 0 or 1, with 50% chance each. So the chance of that if statement would always be 50%.
@BluecoreG7 жыл бұрын
Woops, meant to write. if (70 > irandom (100)) That way you actually have a 70% chance of true, and "70" may be easier for someone to read and understand than "0.7"
@HM1xx7 жыл бұрын
if (100 > irandom(100)) // false with 1/101 chance
@tonystroemsnaes5547 жыл бұрын
umm
@clubpenguinsenpai64826 жыл бұрын
at the beginning of approach it says wave
@zheckman896 жыл бұрын
I don't really know why that Wrap function is as complicated as it is, but if you tried copying it and it's annoying you try this one out instead. It will have a small problem where if your value is less than min - (max-min), but as long as you're not using the function with steps larger than (max-min) you should be OK. Or just feel free to fix that corner case, would probably be easier than the wrap in the video. /// @description wrap(value, min, max) /// @param value /// @param min /// @param max var _val = argument0; var _min = argument1; var _max = argument2; if( _val > _max ) _val = _min + (_val % _max); else if( _val < _min ) _val = _max - (_min - _val); return _val;
@raydin94857 жыл бұрын
I'm new to coding and still learning python. Once I downloaded gamemaker, I understood some of the things but most of it didn't make sense to me. So are scripts basically like functions where there are pre-defined functions and functions that you can make?
@icouch57816 жыл бұрын
Yeah, they're basically just global functions.
@CaptainMangles7 жыл бұрын
I think you named the first script wrong in this video.
@funkyb65987 жыл бұрын
Thanks for the tutorial!
@rinrin47116 жыл бұрын
I am not a native english speaker, so i might have got it wrong but as I understand it, the Wrap() function should make something like a loop between _min and _max so the _val always stays inside this interval. If I got it right, then this line of code should be able to replace all of the code under variable definition: "return ((_val - _min) mod (_max - _min + 1)) + min;". I really want to know if I missed something, cause this code works perfectly on paper) EDIT_1: Ok, I have just realised that in GML -2 mod 7 = -2 and not 5, and it doesn't work with real numbers... I'm a bit disappointed in GML now:c EDIT_2: This code below works perfectly for Integer values: /// @description Wrap(value, min, max) /// @function Wrap /// @param value /// @param min /// @param max var _val1= argument0 - argument1; var _val2 = argument2- argument1; return ((_val1 % (_val2+1)) + (_val2 & -(_val1 < 0))) + argument1;
@davidlecompte94675 жыл бұрын
what the difference with doing a script and doing a variable with the script ? is it just 2 option i have ?
@TheFatHampster5 жыл бұрын
well if you do var ScriptOutput = scriptName(); and your script returns for instance "potato" then ScriptOutput will be "potato". Make sense? just a way of storing the returned value of the script.
@AlexFerran7 жыл бұрын
What's the difference between Wrap and just val = (val mod max-min) + min?
@SonictheHedgehogInRealLife2 жыл бұрын
Does anyone know how to do the approach script in C#?
@UltimoGames7 жыл бұрын
I find it weird that GameMaker 8.1 isn't available for free download on the YoYoGames website..
@leochima60427 жыл бұрын
im pretty sure that version doesnt exist...
@DiamondWolfX7 жыл бұрын
It does. Ever since Studio they stopped supporting it though.
@H0gwashing6 жыл бұрын
6:57 actually, if it's testing it to be more than 0.7, then that means it only has a 30% chance of happening
@williamwolfe9622 жыл бұрын
wrongo, its testing if .7 is greater than the random number, so .1-.6 return true, .7-.9 return false.
@H0gwashing2 жыл бұрын
@@williamwolfe962 i am a dipshit, thank you
@jakob64557 жыл бұрын
Could anyone tell me what is the best way to resize sprites? I want to make them bigger, but the strange effect appears. I need the solution.
@leochima60427 жыл бұрын
you can change the "interpolate colours between pictures" thing in global game settings and the effect wont appear, i think
@VICE-H3RO4 жыл бұрын
Lot of useful scripts :)
@spiralcraft89576 жыл бұрын
new to coding but i use window_set_cursor (cr_none) cursor_sprite = spr_CustomCursor ; to set the cursor invis and add a custom one. i add it in the create event of my main player not sure if that's the right place but it works.
@Juanlups4BlogspotEs6 жыл бұрын
Scrip warp need speed or something? It dont works
@cristobalvarela935 жыл бұрын
someone knows if there is a videos of the GameMaker Studio 2 in spanish (using drag and drop)
@kugelogaming65107 жыл бұрын
is there a command to check if a variable is not set?
@DiamondWolfX7 жыл бұрын
There is variable_local/global_exists, but GMS1 skipped that... At least they brought it back in GMS2
@Karak-_-4 жыл бұрын
Variable_instance_exists(id,"variable") Id is id of instance and "variable" is string with name of variable.
@The_hangman17 жыл бұрын
What i learn here can i use on unreal?
@mahmoud.zayedd7 жыл бұрын
real time in game maker please . :)
@zarkha_6 жыл бұрын
My Wave() don’t work on game maker studio 1... :(
@knotenamschaft94795 жыл бұрын
mine does
@cameronsanders41697 жыл бұрын
What language do you use in game maker?
@JoelLikesPigs7 жыл бұрын
GML it's its own language
@massim0g7 жыл бұрын
Yeah, it's based on C.
@Sagitta627 жыл бұрын
shout out for C/C++ aka Cpp once you know the basic GML is a breeze
@truebitoy15977 жыл бұрын
There's lerp in GMS so there's no need for the Approach script
@DiamondWolfX7 жыл бұрын
Lerp is for relative values (50% between the numbers) where Approach is for absolute values (50 above the number).
@BloonyFox5 жыл бұрын
chance script is most easy to use in this mode /// @description Chance(percent) /// @param percent // Returns true or false depending on RNG // ex: // Chance(70); -> Returns true 70% of the time // I change 0.7 to 70 to more like a real percentage return argument0 > random(100); // I change 1 to 100, to do more easy select a percentage
@odaghast7 жыл бұрын
My own wrap. idk if its better, worse or doesnt work... var a = argument[0]; var b = argument[1]; var c = argument[2]; var r = (a-b+c) mod c; return r+b;
@Karak-_-4 жыл бұрын
Thou shall name your variables descriptively.
@AgentAvis7 жыл бұрын
Cool i'm getting gamedev adds on gamedev videos.
@Elf0Adrianus7 жыл бұрын
Wow, those scripts look like very useful! :) If all are free for commercial use? Maybe it's obvious question but I'm start use GMS2 newly and I newbie in this things.
@Axolotine7 жыл бұрын
For my fellow script kiddies, here's all the code in this video (slightly cleaned up and with more documentation): puu.sh/wWGNv/835d4d702a.zip
@alexaquila66487 жыл бұрын
Kinda late to this video but thanks for the efforts, you haven't been ignored
@DecayingEkzykesFan3 жыл бұрын
The link is dead... I shall die with it
@BriBrando7 жыл бұрын
Hey can yah make a super fnaf tutorial on game maker 1
@RoyFlaherty7 жыл бұрын
I doubt he'd do something super specific. Maybe just learn the GameMaker Language to code it yourself
@greatduck52977 жыл бұрын
a fnaf tutorial wouldn't make sense. More likely, he'd do an AI tutorial on arbitrary directed graph maps.
@problemshed6 жыл бұрын
fucking superb you funky little cowboy
@KirmesMan7 жыл бұрын
Fress!
@Watermelonsa7 жыл бұрын
Thx
@greatduck52977 жыл бұрын
for what?!? dont spam.
@Goatnime7 жыл бұрын
I wish i had my PC so i could use this ;-;
@shogunero3.67 жыл бұрын
Herofang don't you have any kind of computer???
@Goatnime7 жыл бұрын
アルジュン Yumeito I had one but my computer messed up really bad beyond repair :(
@TheRexion7 жыл бұрын
I think you might be too close to your microphone. I can hear your lips smacking every time you talk and it is just unbearable for me.
@loconnor10657 жыл бұрын
Why go to the effort to make something so shit for a product no one cares about