• 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!

2D Physics - Projectile?

E

Edmen12

Guest
Hello there! I was wondering how I could for example, make a fireball shoot the direction I am facing after an animation ends.

So far I know how to create a fireball in the direction I am facing after the animation but I just don't know how to make it move in the direction I am facing.

Can anyone help me?
 

Jakylgamer

Member
Code:
var FB = instance_create(x,y,obj_fireball);
FB.direction =direction;//set the direction of the fireball based on the object creating it
FB.speed = 10;//set the speed of the fireball
is a simple way of creating an object and setting a speed and direction based on the object creating it
 
E

Edmen12

Guest
Code:
var FB = instance_create(x,y,obj_fireball);
FB.direction =direction;//set the direction of the fireball based on the object creating it
FB.speed = 10;//set the speed of the fireball
is a simple way of creating an object and setting a speed and direction based on the object creating it
So I put this code where the fireball is created right?
 

Jakylgamer

Member
think of FB as the object fireballs id for when its created (but only used for this script, it cant be used elsewhere)
 
E

Edmen12

Guest
think of FB as the object fireballs id for when its created (but only used for this script, it cant be used elsewhere)
So is this code supposed to be used in a script or in an event of the obj? Like the create event or something. Cause I put it in the step event and my game crashed and ran out of memory so then I tried putting it in the create event and that didn't work either, I'm not sure where exactly to enter this code.

In the Object itself or in the State Machine that creates the object after the animation is over?
 
J

jackhigh24

Guest
are you using the built in physics, if so then you need to use impulse in a create event, speed does not work with physics objects.
 

Jakylgamer

Member
So is this code supposed to be used in a script or in an event of the obj? Like the create event or something. Cause I put it in the step event and my game crashed and ran out of memory so then I tried putting it in the create event and that didn't work either, I'm not sure where exactly to enter this code.

In the Object itself or in the State Machine that creates the object after the animation is over?
you would call that code when you want the object to be created
its best to call this from an event that happens only once or is triggered by a key pressed event
 
Top