5 Useful Scripts for GameMaker Studio 2 (and 1!)

  Рет қаралды 101,407

Sara Spalding

Sara Spalding

Күн бұрын

Пікірлер
@SaraSpalding
@SaraSpalding 4 жыл бұрын
!!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
@andreseungyeobsong4899
@andreseungyeobsong4899 4 жыл бұрын
Thanks for the update!
@dopamine7344
@dopamine7344 4 жыл бұрын
so what do we need to do to fix it D: very new to gamemaker lol
@SaraSpalding
@SaraSpalding 4 жыл бұрын
@@dopamine7344 Use the same code but wrap them in a function definition, for example: function Approach() { (code goes here) }
@dopamine7344
@dopamine7344 4 жыл бұрын
@@SaraSpalding oh thank you! I 100% overthought it and figured you had to do a lot more, thanks dude c:
@apollolane8879
@apollolane8879 3 жыл бұрын
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_Insanity
@Tezla_Insanity 7 жыл бұрын
Odd moment when your watching a tutorial for Gamemaker and a Unity advertisement appears.
@kahztein1397
@kahztein1397 7 жыл бұрын
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)
@EnzuccioGameplays
@EnzuccioGameplays 7 жыл бұрын
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
@kolegaramic260
@kolegaramic260 7 жыл бұрын
Make this a series, you can make shaders top 5 like this
@Jorvanius
@Jorvanius 6 жыл бұрын
Oh, man, that's the one.
@adamprokop
@adamprokop 5 жыл бұрын
​@@Jorvanius I agree!!
@zedkhov
@zedkhov 7 жыл бұрын
Thanks for posting these Shaun. Already making use of a couple of them in a prototype. Saved me a decent amount of time :)
@SyntekkTeam
@SyntekkTeam 7 жыл бұрын
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 :)
@anintendofankindaguy1368
@anintendofankindaguy1368 7 жыл бұрын
Scripts, they save sanity.
@sparkyspartan5112
@sparkyspartan5112 7 жыл бұрын
oh my, I needed the wrap() script badly for the longest time! Super useful video
@St3fa9s
@St3fa9s 9 ай бұрын
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 :)
@didjargo
@didjargo 7 жыл бұрын
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.
@GoldScale57
@GoldScale57 7 жыл бұрын
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.
@anonymous1808
@anonymous1808 4 жыл бұрын
Oh? You're Approach()ing me?
@St3fa9s
@St3fa9s 9 ай бұрын
If (you're approach()ing) run(away); }
@DragoniteSpam
@DragoniteSpam 7 жыл бұрын
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
@DJaycerOfficial
@DJaycerOfficial 6 ай бұрын
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.
@benedictnothing
@benedictnothing 7 жыл бұрын
Cheers for these tutorials, matey. You're a proper legend.
@sabriath
@sabriath 4 жыл бұрын
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
@IceMetalPunk
@IceMetalPunk 6 жыл бұрын
The Wrap script could also be turned into two lines... while (argument0 < argument1) { argument0 += argument2; } return argument0 % argument2;
@amazingsparckman
@amazingsparckman 7 жыл бұрын
whoa cool scripts le Shaun! I am be tryin' this later on.
@MarioVelezBThinkin
@MarioVelezBThinkin 7 жыл бұрын
That wrap one helps a lot.
@TJCorporation
@TJCorporation 7 жыл бұрын
Can you post a link to copy and paste these scripts?
@Aresous
@Aresous 7 жыл бұрын
yeah fr, very tedious having to type the whole thing.
@Aresous
@Aresous 7 жыл бұрын
thanks mate
@EnzuccioGameplays
@EnzuccioGameplays 7 жыл бұрын
Thanks a lot. Very helpful, as always ^^
@Axolotine
@Axolotine 7 жыл бұрын
puu.sh/wWGNv/835d4d702a.zip (a zip file with all the code in the vid cleaned up and with more documentation)
@Aresous
@Aresous 7 жыл бұрын
axolotine, appreciate the effort homie.
@DiamondWolfX
@DiamondWolfX 7 жыл бұрын
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.
@WangleLine
@WangleLine 5 жыл бұрын
These are super useful, thanks!
@illdie314
@illdie314 7 жыл бұрын
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;
@DINGOS30
@DINGOS30 7 жыл бұрын
wow this was a great code reference video I'm keeping this one thnx Shaun!😉
@mushroomdude123
@mushroomdude123 7 жыл бұрын
I've been struggling to make a bird enemy in my game, that wave script is perfect for that!
@joshuacahill2139
@joshuacahill2139 7 жыл бұрын
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
@IceMetalPunk
@IceMetalPunk 6 жыл бұрын
The approach script could be made much, much shorter: return argument0 + sign(argument1 - argument0) * min(argument2, abs(argument1 - argument0))
@Diegovz01
@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?
@NickoTyn
@NickoTyn 7 жыл бұрын
But I like your voice on the internet. Keep up the good work.
@kanolem
@kanolem Жыл бұрын
hello, if it's possible. Can you make an updated version for this useful scripts.
@guycomments
@guycomments 7 жыл бұрын
you should make more videos featuring more small quality of life type scripts like these
@Eddygeek18
@Eddygeek18 5 жыл бұрын
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
@lionjeff1640
@lionjeff1640 3 жыл бұрын
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-ir1bc
@Rocky-ir1bc 5 жыл бұрын
the wave script is just... perfect...
@myleskerwin2
@myleskerwin2 5 жыл бұрын
The wrap joke was the best!
@gms2378
@gms2378 7 жыл бұрын
I must be sincere, before GMS2 I wasn't following you... but those videos are great so, good job Shaun!
@foof7352
@foof7352 5 жыл бұрын
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.
@slaz8761
@slaz8761 7 жыл бұрын
Very helpful videos, just like the others XD
@ShmargleFoil
@ShmargleFoil 7 жыл бұрын
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;
@igorthelight
@igorthelight 7 жыл бұрын
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;
@victorstk
@victorstk 6 жыл бұрын
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."
@jinwookim9128
@jinwookim9128 4 жыл бұрын
You are god of GMS2 Thank you for your video.
@cube_cup
@cube_cup 7 жыл бұрын
It says Wave() when you explain Approach()
@LuigiXHero
@LuigiXHero 7 жыл бұрын
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.
@ZacDevDude
@ZacDevDude 5 жыл бұрын
Absolutely want more videos like this! Love the Approach script.
@SuperBucketbot
@SuperBucketbot 7 жыл бұрын
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?
@SuperBucketbot
@SuperBucketbot 7 жыл бұрын
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. :)
@icouch5781
@icouch5781 6 жыл бұрын
Sorry to bother, but what was the solution? I guess Shaun deleted his reply.
@victorstk
@victorstk 6 жыл бұрын
i want to see the solution also please
@peppermintgal4302
@peppermintgal4302 6 жыл бұрын
@@icouch5781 Probably something like having a timing variable to base the wave on, rather than using the time the game has been running for?
@BluecoreG
@BluecoreG 7 жыл бұрын
Wouldn't it be better to use if (70 > irandom (100))
@einsfuffzich
@einsfuffzich 7 жыл бұрын
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%.
@BluecoreG
@BluecoreG 7 жыл бұрын
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"
@HM1xx
@HM1xx 7 жыл бұрын
if (100 > irandom(100)) // false with 1/101 chance
@tonystroemsnaes554
@tonystroemsnaes554 7 жыл бұрын
umm
@clubpenguinsenpai6482
@clubpenguinsenpai6482 6 жыл бұрын
at the beginning of approach it says wave
@zheckman89
@zheckman89 6 жыл бұрын
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;
@raydin9485
@raydin9485 7 жыл бұрын
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?
@icouch5781
@icouch5781 6 жыл бұрын
Yeah, they're basically just global functions.
@CaptainMangles
@CaptainMangles 7 жыл бұрын
I think you named the first script wrong in this video.
@funkyb6598
@funkyb6598 7 жыл бұрын
Thanks for the tutorial!
@rinrin4711
@rinrin4711 6 жыл бұрын
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;
@davidlecompte9467
@davidlecompte9467 5 жыл бұрын
what the difference with doing a script and doing a variable with the script ? is it just 2 option i have ?
@TheFatHampster
@TheFatHampster 5 жыл бұрын
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.
@AlexFerran
@AlexFerran 7 жыл бұрын
What's the difference between Wrap and just val = (val mod max-min) + min?
@SonictheHedgehogInRealLife
@SonictheHedgehogInRealLife 2 жыл бұрын
Does anyone know how to do the approach script in C#?
@UltimoGames
@UltimoGames 7 жыл бұрын
I find it weird that GameMaker 8.1 isn't available for free download on the YoYoGames website..
@leochima6042
@leochima6042 7 жыл бұрын
im pretty sure that version doesnt exist...
@DiamondWolfX
@DiamondWolfX 7 жыл бұрын
It does. Ever since Studio they stopped supporting it though.
@H0gwashing
@H0gwashing 6 жыл бұрын
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
@williamwolfe962
@williamwolfe962 2 жыл бұрын
wrongo, its testing if .7 is greater than the random number, so .1-.6 return true, .7-.9 return false.
@H0gwashing
@H0gwashing 2 жыл бұрын
@@williamwolfe962 i am a dipshit, thank you
@jakob6455
@jakob6455 7 жыл бұрын
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.
@leochima6042
@leochima6042 7 жыл бұрын
you can change the "interpolate colours between pictures" thing in global game settings and the effect wont appear, i think
@VICE-H3RO
@VICE-H3RO 4 жыл бұрын
Lot of useful scripts :)
@spiralcraft8957
@spiralcraft8957 6 жыл бұрын
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.
@Juanlups4BlogspotEs
@Juanlups4BlogspotEs 6 жыл бұрын
Scrip warp need speed or something? It dont works
@cristobalvarela93
@cristobalvarela93 5 жыл бұрын
someone knows if there is a videos of the GameMaker Studio 2 in spanish (using drag and drop)
@kugelogaming6510
@kugelogaming6510 7 жыл бұрын
is there a command to check if a variable is not set?
@DiamondWolfX
@DiamondWolfX 7 жыл бұрын
There is variable_local/global_exists, but GMS1 skipped that... At least they brought it back in GMS2
@Karak-_-
@Karak-_- 4 жыл бұрын
Variable_instance_exists(id,"variable") Id is id of instance and "variable" is string with name of variable.
@The_hangman1
@The_hangman1 7 жыл бұрын
What i learn here can i use on unreal?
@mahmoud.zayedd
@mahmoud.zayedd 7 жыл бұрын
real time in game maker please . :)
@zarkha_
@zarkha_ 6 жыл бұрын
My Wave() don’t work on game maker studio 1... :(
@knotenamschaft9479
@knotenamschaft9479 5 жыл бұрын
mine does
@cameronsanders4169
@cameronsanders4169 7 жыл бұрын
What language do you use in game maker?
@JoelLikesPigs
@JoelLikesPigs 7 жыл бұрын
GML it's its own language
@massim0g
@massim0g 7 жыл бұрын
Yeah, it's based on C.
@Sagitta62
@Sagitta62 7 жыл бұрын
shout out for C/C++ aka Cpp once you know the basic GML is a breeze
@truebitoy1597
@truebitoy1597 7 жыл бұрын
There's lerp in GMS so there's no need for the Approach script
@DiamondWolfX
@DiamondWolfX 7 жыл бұрын
Lerp is for relative values (50% between the numbers) where Approach is for absolute values (50 above the number).
@BloonyFox
@BloonyFox 5 жыл бұрын
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
@odaghast
@odaghast 7 жыл бұрын
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-_-
@Karak-_- 4 жыл бұрын
Thou shall name your variables descriptively.
@AgentAvis
@AgentAvis 7 жыл бұрын
Cool i'm getting gamedev adds on gamedev videos.
@Elf0Adrianus
@Elf0Adrianus 7 жыл бұрын
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.
@Axolotine
@Axolotine 7 жыл бұрын
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
@alexaquila6648
@alexaquila6648 7 жыл бұрын
Kinda late to this video but thanks for the efforts, you haven't been ignored
@DecayingEkzykesFan
@DecayingEkzykesFan 3 жыл бұрын
The link is dead... I shall die with it
@BriBrando
@BriBrando 7 жыл бұрын
Hey can yah make a super fnaf tutorial on game maker 1
@RoyFlaherty
@RoyFlaherty 7 жыл бұрын
I doubt he'd do something super specific. Maybe just learn the GameMaker Language to code it yourself
@greatduck5297
@greatduck5297 7 жыл бұрын
a fnaf tutorial wouldn't make sense. More likely, he'd do an AI tutorial on arbitrary directed graph maps.
@problemshed
@problemshed 6 жыл бұрын
fucking superb you funky little cowboy
@KirmesMan
@KirmesMan 7 жыл бұрын
Fress!
@Watermelonsa
@Watermelonsa 7 жыл бұрын
Thx
@greatduck5297
@greatduck5297 7 жыл бұрын
for what?!? dont spam.
@Goatnime
@Goatnime 7 жыл бұрын
I wish i had my PC so i could use this ;-;
@shogunero3.6
@shogunero3.6 7 жыл бұрын
Herofang don't you have any kind of computer???
@Goatnime
@Goatnime 7 жыл бұрын
アルジュン Yumeito I had one but my computer messed up really bad beyond repair :(
@TheRexion
@TheRexion 7 жыл бұрын
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.
@loconnor1065
@loconnor1065 7 жыл бұрын
Why go to the effort to make something so shit for a product no one cares about
GameMaker Quick Tip: lengthdir_x & lengthdir_y
1:32
Sara Spalding
Рет қаралды 16 М.
Beginner GameDev Mistakes - Ep 1
6:40
Sara Spalding
Рет қаралды 167 М.
СИНИЙ ИНЕЙ УЖЕ ВЫШЕЛ!❄️
01:01
DO$HIK
Рет қаралды 3,3 МЛН
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 53 МЛН
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН
GameMaker Studio 2 - Best Saving and Loading Tutorial (2.3.1+)
23:01
The 15 Commandments of Game Maker
16:32
PixelatedPope
Рет қаралды 125 М.
Object States | Game Maker Studio 2
22:21
FriendlyCosmonaut
Рет қаралды 140 М.
The Latest Celebrity Tech Scam…
19:21
Linus Tech Tips
Рет қаралды 2,5 МЛН
Resolution and Aspect Ratio Management for Game Maker - Part 1
10:24
PixelatedPope
Рет қаралды 114 М.
Organising Data | Menus: GMS2 [P1]
28:19
FriendlyCosmonaut
Рет қаралды 69 М.
GameMaker Studio 2: Music Tutorial
16:53
Sara Spalding
Рет қаралды 75 М.
Concepts & Setup | Cutscenes [1]
19:48
FriendlyCosmonaut
Рет қаралды 51 М.
Forget WiFi AGAIN! This Wireless Method is WAY Better?
12:05
GreatScott!
Рет қаралды 15 М.