GameMaker [SOLVED]Step Event Issue

T

This Thing

Guest
Hi my game is simple so far: Top Down view where you navigate an orb with WASD.

My problem is that I need different other objects to stick to my o_player. In this case a o_gun.
I went about it by adding this in the Step Event:

x = o_player.x;
y = o_player.y;
However, it acts as if I put it into the Begin Step and the o_gun kind of 'drags' with the player. The o_gun's movement seems delayed. I usually put such objects into Begin Step if I want that specific 'drag' effect, but in this case it is important that o_gun moves with o_player without the delay/drag.

What can cause this? I have no clue where to look for code that might cause this and I am in no way close a pro. I am still learning. Any help is much appreciated and I will provide any more info if needed!
 

Slyddar

Member
What can cause the lag is the order that events run in GM. If the players step code hasn't run this step, but the o_gun runs their step code, it gets the x and y coordinates and moves to that spot. Then later in the same step the player does their move, they will be in a different position, and that will make the gun lag behind them.

Try moving that code to o_gun's End Step event which will give time for the player to move.
 
T

This Thing

Guest
What can cause the lag is the order that events run in GM. If the players step code hasn't run this step, but the o_gun runs their step code, it gets the x and y coordinates and moves to that spot. Then later in the same step the player does their move, they will be in a different position, and that will make the gun lag behind them.

Try moving that code to o_gun's End Step event which will give time for the player to move.
What more can I ask for: Fast reply, easy (even for me) to understand and... It worked!
Thank you so much and if I owned Android or IOS I would certainly check your game out.
Again thanks for replying so fast and for the help. Good day.
 
Top