Need Help With Coding Weapon Movement With Player

C

ColinTheGamer

Guest
Hello, I'm currently having and issue with my weapon not following me properly. It follows me as I move and fires correctly, but there's a delay when it follows me that makes it look like it's floating in front of me rather than being held by me. The code I used is very simple, I'll post it below.

(In the "Begin Step" for my weapon)

x = o_Player.x+4;
y= o_Player.y;

Like I said it works to make the gun appear where I want it to, but it doesn't properly keep up with my player. I'll post a video below to show what I mean.
 

Attachments

Nidoking

Member
Presumably, you're moving the o_Player after the Begin Step event, such as in the Step event. You need to move the weapon after the player has moved.
 
C

ColinTheGamer

Guest
Ah, that makes sense. How would I code the weapon to do that? I've tried adjusted it's speed but nothing I've done works.
 

TomOmNom

Member
Just move the code to the End Step event. You can also change the instance creation order, but it's more organized approach to use end step.
 

Tyg

Member
I never use begin step..i would put it in step event that way your know it will run with the other step code
but another way is you could force the event in the player step event with event perform
event_perform(ev_step, ev_step_begin); could be forced to run in your player step code to sync it
but why not just update it in the player step event gux.x = x; gun.y = y;
Hope that helps :)
 
C

ColinTheGamer

Guest
Thanks guys, that completely fixed it. I deleted the begin and end step event and just copied the code into a step event, now it works perfectly.
 
Top