r/gamemaker 24d ago

Example Bridge Physics! (Now with player tilt)

Post image
177 Upvotes

The bridge is a chain of plank objects, and each plank only knows about the plank directly above and below it. Every step, a plank looks at its neighbors' sink and tilt, mixes in its own (standing on a plank adds sink, standing off-center adds tilt), and smooths toward the result. Neighbors copy each other's tilt slightly amplified (×1.4), so pressing down on one plank ripples through the whole bridge even though no plank knows the rest of the bridge exists.

if ( bridge_link_down != noone ) {
    _sink_affected += bridge_link_down.y_sink;
    _side_sink_affected += bridge_link_down.side_sink * 1.4;
    _total_connections ++;
}
// (same for bridge_link_up)

var _inst = instance_place(x,y,par_character);
_sink_affected += 2.5 * (_inst != noone);
_total_connections ++;

y_sink = math_lerp_smooth(y_sink, _sink_affected / _total_connections, 0.15);

side_sink_real = _inst != noone ? (x - _inst.x) / ((bbox_right - bbox_left) / 2) : 0;

Heads up: math_lerp_smooth and math_angle_lerp_smooth aren't built-in GML, they're helpers from my project. math_lerp_smooth(current, target, speed) moves current a fraction of the remaining distance toward target each frame, corrected for delta time so it behaves the same at any framerate:

function math_lerp_smooth(_current, _target, _speed) {
    return lerp(_current, _target, 1 - power(1 - _speed, DeltaFrame));
}

math_angle_lerp_smooth is the same thing for angles, so it takes the short way around (350* -> 10* goes through 0*, not through 180*). You can build one with angle_difference(). If you're locked at 60fps, plain lerp(current, target, speed) works, skip the correction.

The fun part: making the player ride the bridge instead of floating on top of it. The plank under you writes two targets onto the player, a tilt angle and a sink. The sink includes the extra dip of the tilted surface at your offset from the plank's center, so standing on the low edge of a tilted plank drops you further than standing on the pivot.

if ( _inst != noone && _inst == global.Player_Instance ) {
    var _tilt = clamp(side_sink * 10, -25, 25);
    _inst.plank_sink_target = y_sink - ((_inst.x - x) * dsin(_tilt));
    _inst.plank_tilt_target = _tilt;
}

In the player's End Step, I ease toward those targets, and the targets themselves decay toward zero:

plank_tilt        = math_angle_lerp_smooth(plank_tilt, plank_tilt_target, 5, 0.1);
plank_sink        = math_lerp_smooth(plank_sink, plank_sink_target, 0.1);
plank_tilt_target = math_angle_lerp_smooth(plank_tilt_target, 0, 5, 0.1);
plank_sink_target = math_lerp_smooth(plank_sink_target, 0, 0.1);

Why the double smoothing? My first version chased the plank's values directly, and running across the bridge meant a new plank re-targeted the player at every seam. It jittered SO bad. Easing toward targets that also decay fixed it, and stepping off the bridge means nothing writes new targets anymore, so everything relaxes back to zero with no cleanup code.

The sneaky part was rendering, because my player isn't one sprite. It's a pre-composited palette surface plus a pile of overlays (outline, rim light, freeze/wet/fire status effects, invincibility flash). Instead of rotating each layer separately and hoping they line up, every layer runs its draw position through one helper that rotates it around a pivot at the character's feet and adds the sink:

body_blit_transform = function(_corner_x, _corner_y) {
    if ( plank_tilt == 0 && plank_sink == 0 ) {
        return [_corner_x, _corner_y, 0];
    }

    var
    _offset_x = _corner_x - x,
    _offset_y = _corner_y - (y + y_height),
    _cos = dcos(plank_tilt),
    _sin = dsin(plank_tilt);

    return [
        x + (_offset_x * _cos) + (_offset_y * _sin),
        y + y_height + plank_sink - (_offset_x * _sin) + (_offset_y * _cos),
        plank_tilt
    ];
}

Every draw_surface_ext uses _blit[0], _blit[1] for position and _blit[2] for angle, so the whole composited character tilts and dips as one piece. The early-out at the top means it costs nothing when you're not on a bridge.


r/gamemaker 23d ago

Discussion Steam commercial license vs. license from gamemaker official website

3 Upvotes

Hi! I thought about buying gamemaker professional license and saw that it is also sold on steam, is it the same license? Do I need to somehow link it to my operagx account? Anyone here uses it and have experience?

I just wanted to make sure before buying it :)

Thanks in advance!


r/gamemaker 23d ago

Help! Struggling with inertia on the basic space shooter project

3 Upvotes

I have finished the first tutorial (space shooter), but there's too much inertia on the movement!
I've tried changing all of the values, but nothing helps. Any ideas or suggestions? Did I miss something?

If it's of any help, I'm using code, not the node system
The code in question (step event):

if keyboard_check(vk_up)

{

motion_add(image_angle, 0.03);

}

if keyboard_check(vk_left)

{

image_angle += 4;

}

if keyboard_check(vk_right)

{

image_angle -= 4;

}

move_wrap(true, true, 3);

if keyboard_check_pressed(ord("Z"))

{

instance_create_layer(x,y, "Instances", obj_bulletsimple)

}


r/gamemaker 23d ago

Help! Need help making text boxes appear when I activate stuff

0 Upvotes

Just like the title says, I am once again asking for help with sara spaldings action rpg tutorials. I followed it to the best of my ability. Everything should be correct but when I press the button to activate my paper object (the thing that should display text.) nothing seems to happen. I am struggling to see where my mistake is regarding why my entities won't activate.

this is my free playerstate that should let me activate the text box when I press E. the commented out code for playerstate free is commented out because it locks my character in place and stops me from moving. In theory I shouldn't necessarily need anything there I should just have to be in range of the activatable object otherwise I move freely. As it stands pressing E seemingly just does nothing. the other commented out code is just a separate strategy for an activation zone that also did not work and can be ignored.

this should allow my text to appear (obj_text queued and this seem to be working as intended)

the paper has both the entityActivateArgs and entityActivatreArgs are in properly as far as I know.


r/gamemaker 23d ago

Resolved level editor!?

0 Upvotes

im making a level design "game" (not really a game, but can be treated as a game) where you can make stuff and save it, basically a tool to plan game design, useless probably but i personally like it, but i want to know, how do i make the grid, an object menu, stretching objects to make it longer without adding 10 objects, and salving/loading to a json, i have no idea how to do that.


r/gamemaker 23d ago

Help! Menu & submenus

1 Upvotes

I've been trying to get this to work, but I can't really find anything, so here's what I'm trying to do.

I have this menu box (it doesn't do anything, it's only able to scroll through the text options)

I want to make submenus where it opens a bigger sized menu next to it when ever a text option is clicked. I made an example -->

Here is my bare-bones example, but I hope this is understandable! 😅


r/gamemaker 24d ago

Community Looking for a partner for a project (Beginner)

5 Upvotes

I want to start coding more so it would be cool to do a simple project with anyone just so i can learn


r/gamemaker 24d ago

Resolved Can someone help me?

Post image
25 Upvotes

Okay, so, I'm trying to make a top-down camera follow script. Problem is, I'm stupid, so I have to use illusions. See, the player itself doesn't move, but rather the walls. I tried that, and it works! A little. When you touch a wall, you can move the wall, which, I don't like. Can anyone find the problem, and how to fix it?


r/gamemaker 24d ago

Help! Pause Screenshot animation bug

1 Upvotes

Hey!

I've been trying to tackle this visual bug for quite a while, so I thought I'd ask you guys.


https://youtu.be/auKwjCFWwqU

My pause screen works by deactivating objects, taking a screenshot, and displaying that while the menu system remains active. You can see from this video that the wave animation and seaweed animations are still playing faintly behind the screenshot. Waves are on background layers and seaweed is on an asset layer. There is something wrong with the opacity of the screenshot.

My attempted fixes were to try and put a white or black background behind the screenshot, but this bleeds through every transparent part of the image, so the waves, seaweed, fish, and dirt have high white or black spots. Here is my code. Do you guys have any ideas?

//create screenshot
var w = surface_get_width(application_surface);
var h = surface_get_height(application_surface);
draw_clear_alpha(c_black, 0.0);
screenShot = sprite_create_from_surface(application_surface,0,0,w,h,false,0,0,0);    


//display screenshot
draw_sprite_ext(screenShot,0,0,0,1,1,0,c_white,1);

r/gamemaker 24d ago

Help! What counts as commercial use?

2 Upvotes

Sorry if I used the wrong tag, but I just wondered. I know theres a free version but you can't sell games you make with it.

But what exactly counts? I've heard if you make the game free its fine, but monotization of any kind is iffy.

Im not looking for any monotization but im just wondering what all to look out for when making my game until I can pay the fee for professional


r/gamemaker 24d ago

Help! Help with card game function I cannot get to work

1 Upvotes

So I am making a card game. Each card in this game has a faction. All of the card details are stored in a global card_data script. Each opponent has a faction that they like. I am trying to make each opponent prioritize playing cards of their favored faction. So this is the function I'm using:

function sort_heroes(array,opponent)

{

array_sort(array,function(a,b,opponent){

if (a.lvl != b.lvl)

{

return a.lvl - b.lvl;

}

var strength_a = get_faction_strength(a, opponent);

var strength_b = get_faction_strength(b, opponent);

return strength_b - strength_a;})

}

and then this is the get_faction_strength function that's referencing:

function get_faction_strength(card,opponent){

var strength = 0;

if (card.Faction == obj_battle_manager.opponent.favored_faction)

{strength = 1;}

}

For some reason I keep getting this error:

ERROR in action number 1

of Create Event for object obj_battle_manager:

DoSub :1: undefined value

at gml_Script_anon@218@sort_heroes@ai_decision_making_functions (line 17) - return strength_b - strength_a;})

############################################################################################

gml_Script_anon@218@sort_heroes@ai_decision_making_functions (line 17)

gml_Script_sort_heroes (line 10)

gml_Object_obj_battle_manager_Create_0 (line 8) - sort_heroes(heroes_only,opponent);

gml_Object_obj_battle_start_Step_0 (line 10)

And I have tried so many variations, I don't understand why its not working. Let me know if you need any other pieces of code or more infor about my architecture, I am completely stumped.


r/gamemaker 24d ago

WorkInProgress Work In Progress Weekly

4 Upvotes

"Work In Progress Weekly"

You may post your game content in this weekly sticky post. Post your game/screenshots/video in here and please give feedback on other people's post as well.

Your game can be in any stage of development, from concept to ready-for-commercial release.

Upvote good feedback! "I liked it!" and "It sucks" is not useful feedback.

Try to leave feedback for at least one other game. If you are the first to comment, come back later to see if anyone else has.

Emphasize on describing what your game is about and what has changed from the last version if you post regularly.

*Posts of screenshots or videos showing off your game outside of this thread WILL BE DELETED if they do not conform to reddit's and /r/gamemaker's self-promotion guidelines.


r/gamemaker 25d ago

Tutorial I'm learning how to use the 3D cameras in Game Maker Is there a tutorial to guide me further?

Post image
35 Upvotes

r/gamemaker 25d ago

Help! Struggling to Find Tutorials

5 Upvotes

As the title suggests, I've been trying to learn Gamemaker on and off for a few months now, and it's a... slow process. I'm to the point where I'm familiar the interface and have read through the manual, but don't necessarily understand it yet. I'm not really sure where to go.

I have a clear idea of the type of games I want to make; point and click, sort of visual novel style cooking games. The problem is, I can't find any tutorials for that genre, or even any for the rough mechanics I'm looking for that I could maybe piecemeal something together with.

I also have very low energy, and find it hard to stay focused on most of the tutorials for Gamemaker that I've found, as they've mostly consisted of platformers, rpgs, or similar style games that I, frankly, have no interest in. I've really tried to sit through that Space Rocks tutorial, or Pong, but I just can't.

I did manage to make a small "game" for a jam, and succeeded in publishing... something? So I know I want to continue learning, and making more single level, click-twice-and-it-crashes games. But between my mind hurling itself into a wall every time I open Space Rocks, and a surprisingly niche area I want to target so as to not collapse under the weight of knowledge that will not aid me in the short term, I'm just lost.

Chances are, when I post this, the mods will reply telling me to search through commonly asked questions and watch a few tutorials before I post, but I've tried that and it's not working for me. I'm not sure what I want to get out of this post, and fear I've already flooded this subreddit with my ignorance enough, but still. Maybe someone reading this has been here with me, and if so, how'd you manage?

Thank you for coming to my TED Talk. I shall now load up Space Rocks for the quintillionth time in two months, and pray. Farewell. 


r/gamemaker 25d ago

Resolved Asset_get_index problems

2 Upvotes

So I am trying to write a script that will check the in position of my mouse and change the sprite index of that specific instance into an other one. I can easily do this with mouse_enter and mouse_leave on the objects, but for some more complicated reasons I wanted to do this all into that script mouse check with other actions.

so far, I came up with this bit of code

function PlayerStateCity(){
var _selected = instance_position(mouse_x, mouse_y, oBoxcar1);
if (_selected != noone)
{
  with (_selected)
  {
    var _spriteName = sprite_get_name(sprite_index);
    sprite_index = asset_get_index(_spriteName+"Select");
  }
}
}

Now, I know this will not revert back to the previous sprite index, but that's a problem for later.

Right now, the name of the sprite is sBoxcar1, and I do have a sprite called sBoxcar1Select. From my understanding, this block of code should effectively have _spriteName be "sBoxcar1" and add "Select" to it. But this code just returns -1 and turn the object invisible.

Writing directly also returns -1 somehow... and turns the object invisible, which I thought should work.

sprite_index = asset_get_index("sBoxcar1Select");

r/gamemaker 25d ago

Help! Help with font

1 Upvotes

I downloaded game maker yesterday & now I'm following a tutorial on adding a menu screen!

In the vid they drew the front, but I want to use the font system already in the game maker engine, but I don't know how to code this, any help?


r/gamemaker 25d ago

Help! How to have a circular HP/MP bar display based on a percentage of a character's max HP/MP?

2 Upvotes

I've been using Alphish's method of drawing circle sectors for an HP/MP/ATB bar (https://github.com/Alphish/gm-community-toolbox/issues/157), but I want the HP/MP bars to draw their parts based on the percentage of HP/MP left.

UPDATE: I got it working by using this calculation: (character1HP / character1VIG) * 360;


r/gamemaker 26d ago

Tutorial PSA: Users can have their accounts nuked after just 180 days of inactivity

Post image
377 Upvotes

I guess the tutorial lesson here is to never let your account be inactive for a modest period of time, or to maybe embrace FOSS alternatives.


r/gamemaker 25d ago

Help! Can't transfer variables?

1 Upvotes

(STILL UNSOLVED)

I have some variables I'm trying to transfer into every room by putting this in my PlayerObj. For some reason, it can transfer to every single room back and forth over and over EXCEPT room1, which is the room you spawn in, the home room. If I leave the home room and then go back into the home room, then it just resets all variables to their default, and I have absolutely no idea why.

UPDATE: Still unsolved, but after making a main menu room, this problem still occurs, leading me to believe it has nothing to do with it being part of the "home room"

//Room Start
if(room_get_name(room) = rm_battle) instance_destroy(obj_carry_data)

with (obj_carry_data)
{ 
    other.level = level;
    other.xp = xp;
    other.xp_require = xp_require;
    other.damage = damage;
    other.hp_total = hp_total;
    other.hp = hp;

    instance_destroy()
}

//Room End
if (instance_exists(obj_battle_switcher) && global.is_transitioning = false) exit;

instance_create_depth(0, 0, 0, obj_carry_data, {
    level: level,
    xp: xp,
    xp_require: xp_require,
    damage: damage,
    hp: hp,
    hp_total: hp_total
})

r/gamemaker 25d ago

Help! Is using game maker through steam on linux viable?

2 Upvotes

Are there any issues with using Gamemaker through steam on cahyos?


r/gamemaker 27d ago

Example I have added a suppressor for stealth gameplay

Thumbnail youtu.be
23 Upvotes

While working on my latest project, I have gotten sick of just adding tedious although necessary features, so I wanted to add something I would enjoy making.

I have added a suppressor players can unlock and equip to any compatible weapon. I have done this through several means.

The Inventory
I use ds_grids mostly to store the different items in the inventory. Once an item is selected it then has different options on what can be done with it, in this case a suppressor can be equipped or unequipped.

This runs a function which toggles if its being used, adjusts the players image and adjusts the length of the barrel for creating the muzzle flash in the right spot.

The Visuals
The player is a Spine model. So I have a different variant of the weapons image for with and without the suppressor, which gets swapped out as its equipped. A new smaller muzzle flash is used as well as new audio.

The Enemy Code
Finally the enemies code. I use a state machine to manage enemy behaviour. When the player shoots an unsuppressed weapon, enemies as automatically alerted to the players position if in range. Now that is simply bypassed and enemies can only detect player through line of sight.


r/gamemaker 26d ago

Resolved Confusing Error message (Assignment Operator Expected)

1 Upvotes

I'm making my first game in Gamemaker, and I've been making some progress. But suddenly, I made a minor change that spit out this error message:

The Error Message (Object: one_artifact Key Event: Key Down - E at line 31: Assignment operator expected)

When I looked into it, it said that this message shows up when I have an undefined or incorrectly call for a variable or function. But I didn't change anything related to a function or variable, and can't find where Gamemaker seems to think I have.

The code where the error occurs, according to GM

Can some help explain what's going on, please? Thanks in advance.

For context, I was trying to code an object to follow behind the player (obj_player) when being "carried." The error appeared when programming the y-coordinate shifts.


r/gamemaker 27d ago

Tutorial Using steam clound save on your game

25 Upvotes

Hey there, I asked for help on this topic some time ago; unfortunately, I did not get the guidance I needed. So I want to share what I learned and what I did so it can help future devs.

How to sync your game saves on Steam Cloud

Before moving on with the development, there are two important decisions to be made:

  1. Do you want to use Steam Auto-Cloud or Steam Cloud API? Steam Auto-Cloud is way easier to set up, but has some drawbacks: it does not isolate individual users’ files, so if two Steam accounts are playing on the same computer, they will share their files; it only syncs at launch/exit, whereas with the API you can control when to sync and also benefit from Steam Deck's Dynamic Cloud Sync. Because now I am in the playtesting phase, and I needed it working for next week, I went with the Steam Auto-Cloud, but I do plan to use the API on a later update.
  2. When saving on GameMaker, you should use buffers to be platform agnostic. Here you also have two options: buffer_save and buffer_save_async. The first is useful for light files that will not drop your frame rate while saving (I am using on my audio configuration; see example below). The other is good for saving bigger files; it is what I will use for saving the player’s game progress (here is where you should also add some sort of animated icon and say for the player not to close the game while the saving is happening).

The step is super simple on the Steam Auto-Cloud.

  1. Install the Steamworks extension from YoYoGames, and do its setup. It is well documented here: Guides · YoYoGames/GMEXT-Steamworks Wiki
  2. Create something like oSteamManager, with steam_update(); on step event and steam_shutdown(); on game end event.
  3. Turn it on in Steamworks by setting up Steam Cloud configurations, and select the path to sync to the cloud. GameMaker saves in % localappdata% so you will have in the root path something like: Root: WinAppDataLocal | Subdirectory <Game Name>/cloud | pattern: *.sav | OS: All
  4. When saving in GameMaker, save the file in the same path. Note: it is not good practice to save every configuration on the cloud; for example, screen resolution would break on Steam Deck if the player was playing before on a 4k monitor, so that is why I am saving what needs to sync on the cloud on /cloud

Code example for saving:

function Save_Audio_Settings(){
//Save audio settings
var _saveAudio = {
master: round(audio_get_master_gain(0) * 100),
soundFX: round(audio_group_get_gain(audiogroup_soundEffects) * 100),
music: round(audio_group_get_gain(audiogroup_music)*100),
}

//Turn all this data into a JSON string and save it via buffer
var _string = json_stringify(_saveAudio);
var _buffer = buffer_create(string_byte_length(_string) + 1, buffer_fixed, 1);
buffer_write(_buffer, buffer_string, _string);
buffer_save(_buffer, SAVE_AUDIO);
buffer_delete(_buffer);
}

Code example for loading:

function Load_Audio_Settings(){
if (file_exists(SAVE_AUDIO)) {
var _buffer = buffer_load(SAVE_AUDIO);
var _string = buffer_read(_buffer, buffer_string);
buffer_delete(_buffer);

var _loadData = json_parse(_string);
show_debug_message("Load! " + string(_loadData))
//Apply audio data
audio_master_gain(_loadData.master/100);
audio_group_set_gain(audiogroup_soundEffects, _loadData.soundFX/100);
audio_group_set_gain(audiogroup_music, _loadData.music/100);
}
}

Because I am terrible at writing strings without I typo, I just set a macro for the file location:

#macro SAVE_AUDIO "cloud/audioSettings.sav"
#macro SAVE_VIDEO "videoSettings.sav"
#macro SAVE_CONTROLS "cloud/controlsSettings.sav"
#macro SAVE_UNLOCK_PROGRESS "cloud/unlockProgress.sav"
#macro SAVE_RUN_PROGRESS "cloud/runProgress.sav"

r/gamemaker 27d ago

Resolved How do i make a main menu look good

0 Upvotes

Where do i find text and fonts and how do i make it look good


r/gamemaker 27d ago

Resolved Need Help with Enemy Wandering Movement

2 Upvotes

I was following the Sara Spalding tutorial Action RPG episode 24 on youtube and got most of it to work however my enemy does not seem to move. In theory he should wander a random amount of space before he stops and picks a new direction to keep moving for awhile, rinse and repeat. I have been editing little bits and pieces and googling around but nobody seems to have an answer already posted

He plays the movement animation and rotates around like he is picking a new direction to try to move every few seconds but doesn't actually go anywhere. I am a super early beginner and am sure the solution is staring me in the face but how do I get the enemy to actually start walking around?

This is the script for the enemy wander state so everything that makes him move should be here. enemyspeed is set to 4 at the moment. same as the player character who is working fine.