shooting in gamemaker
wazzup guys
im looking for a way for my character to to shoot but i cant find a way to have the bullet with the character.So now whenever i shoot the bullet is somewhere else
im looking for a way for my character to to shoot but i cant find a way to have the bullet with the character.So now whenever i shoot the bullet is somewhere else
Comments
I would do this from your player object in the step event. I'm not exactly sure what you're using for input (I'm guessing mouse) so adapt as needed.
Since in this case I was creating the bullet using the player object I could just use x and y as those would be the player's x and y coords.
If I was creating the bullets and I wanted them to be at the player, but I was not creating them in the player I would need to find the player and then create the bullets using its x and y.
BTW I would recommend using one of the Game Maker help threads http://www.makegamessa.com/discussion/743/game-maker-some-questions
It means there are less threads and provides a centralized resource for people looking at similar issues ;)
Hope this helps, and looking forward to seeing your prototype.
@Cooldudue that depends on how you are determining your character's direction, and how many directions there are. Are you using arrow keys for top down 8 directional movement? Are you doing a platformer where you can only face two directions?
If you're assigning a direction to your player via the direction variable then it would simply be
But you'll need to tell me how you are doing you're player's direction and movement for me to give you what you need ;)
Bullet's Step Event:
Also you should really do the videos @Brondin linked they will help you immensely with using GM.
___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object obj_bullet:
Push :: Execution Error - Variable Get 100143.bullet_direction(100001, -2147483648)
at gml_Object_obj_bullet_CreateEvent_1 (line 2) - __b__ = action_if_variable( bullet_direction, 1, 0 );
############################################################################################
BTW have you checked out the videos that Tom Francis posted, and Brondin linked?
you can get it when you say start a new project and look at selecting top menu tabs "Tutorials"..etc.
Demo's:
Scrolling shooter part1 and 2.
Also check the demo:
Surfaces_Part1 - much more complex but you will learn alot and it comes built in with shooting example for top down games. However, this tutorial demo's collision I do not recommend.
i already figured this out by myself