• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Gravity affecting things that it shouldn't.

Dead Eye

Member
Hello,
I'm having this odd issue where when ever I turn my room physics on it breaks my Gun bullets and stops them from moving. The bullets have nothing to do with physics and the physics are off. The bullets are being moved by the built in speed command. If anyone knows what going on help would be greatly appreciated.
Thanks!
-Dead Eye
 

TheouAegis

Member
When you tell the room to be a Physics World, what you're really doing is telling GM which code to run every step. If the room is a normal room, GM will run the code which checks instances' speed variables and moves them accordingly. If the room is a physics world, then GM will branch off and run the set of code for a physics environment and will no longer automatically move instances.
 

GMWolf

aka fel666
. If the room is a physics world, then GM will branch off and run the set of code for a physics environment and will no longer automatically move instances.
What, is this for real?
I thought it did it on a per instance level.
That's certainly good to know!
 

Dead Eye

Member
Create:
Code:
xspd=...
yspd=...
Step:
Code:
x+=xspd
y+=yspd
I did the same thing before but forever reason my bullets go right, down, diagonally into the ground. I'm still using the direction function to make it go in a certain direction.
 

GMWolf

aka fel666
I did the same thing before but forever reason my bullets go right, down, diagonally into the ground. I'm still using the direction function to make it go in a certain direction.
No you will need to compute the hsp and vsp components. It's simple trigonometry.
 

GMWolf

aka fel666
I don't know the first thing about trigonometry so I guess its time to learn =P.
luckily we have the lengthdir_x and lengthdir_y functions. Look the up!
But, yeah, please learn trig. It is an essential tool for Game Dev.
When you are more confident with math, I would also learn vector math, and eventually matrices.
 

Dead Eye

Member
Ok thanks I will. Idk why that duplicated XD. Probs my sister.
Also can when I sue the draw sprite function for a "flame thrower" will they obey collisions and stuff like that?
 

GMWolf

aka fel666
Ok thanks I will. Idk why that duplicated XD. Probs my sister.
Also can when I sue the draw sprite function for a "flame thrower" will they obey collisions and stuff like that?
draw_sprite function will just draw a sprite. It has nothing to do with collisions.
If you need collisions, you will need to write code to detect and react to collisions.
 

Dead Eye

Member
Alright so using length_dir I came up with a simple code to make the bullets shoot in the direction I want them to.
Code:
x = x + lengthdir_x(xspd,image_angle)
y = y + lengthdir_y(yspd,image_angle)
Speed of bullets defined in the create event.
They both need to be the same number in order for them to work correctly.
 

GMWolf

aka fel666
Alright so using length_dir I came up with a simple code to make the bullets shoot in the direction I want them to.
Code:
x = x + lengthdir_x(xspd,image_angle)
y = y + lengthdir_y(yspd,image_angle)
Speed of bullets defined in the create event.
They both need to be the same number in order for them to work correctly.
If they both need to be the same, then you only need one variable.
You may also want to surge result of lengthdir X/y in variables, since they don't change.
 
Top