Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Hi, could you pls explain the Step event(Player) I don't get it from where does it call the State machine? script_execute(state)? Where is the variable state?

(+1)

It's set up in script player_locals_init, it is always set to one of these "playerstate_" scripts:


(You can quickly find assets by using Ctrl+T for the "go to anything" searcher or middle-clicking the script/asset name in the code editor)

Thank you for the fast reply and sorry that I answer so late. Yea I know that there is a search system. What I meant is the variable state in step event where does it start how does it know what is the first state to call. This is what I was searching for in player_locals_init() there is the beginning of the variable state  state = playerstate_normal. Another question: how could I change the obj_companionblock so it's affected by gravity even it's in the idle state?  i know he creates obj_solidterrain_liftable if that and this happens but is there an easy way to make him be affected with gravity? It looks funny (for me) if one obj_companionblock is standing on another one and you pick the first one out and the other one stands there in the air.  (I'm new to programming so sorry for the silly questions)

(1 edit)

There's a variable state_idle which lets you change the idle behavior (what the object does when nobody is lifting it). Copy liftablestate_idle into a new script "liftablestate_idle_with_gravity", and then add some code for the gravity here (and then don't forget to update the liftables you want to have gravity when idle so they use this script for their idle state instead).

For the gravity code, the easiest would be to just check liftable_free(x,y+4) and if free, move down 4 pixels (constant speed instead of using actual gravity). If you want actual gravity, it's probably easiest to copy player_inertia_y's yspeed code and removing the "shockwave when hitting blocks" bit.

I did as you said and added constant speed if liftable_free(x,y+4) but nothing happens if I go !place_meeting(x,y-1,obj_solid_terrain) it moves and collides with the object but only with that object (as expected) so my question did I call it wrong or does the liftable_free(x,y) need something more? 

liftable_free just checks if the position is free of collisions, you also need to move the object:

if(liftable_free(x,y + 4)){
  y += 4
}

Yea that was my first guess but nothing happens.

Okay, I think I've found the cause: the liftable is colliding with itself (rather, its "idle prop") so we need a special exception for that. Something like this should work better:

var blocked = false;
with(parent_terrain){   if(place_meeting(x,y - 4,other)){     if(id != other.idleprop){       blocked = true;     }   } }
if(!blocked){   y += 4   with(idleprop){     y += 4   } }