U
Unkn0wn
Guest
Hello and thank you for reading this post!
I'm terribly sorry that these questions are probably really dumb!
I am making a 2d zombie shooting game as a project for school, but I'm not very good with GameMaker studio 2, in fact, I'm a complete noob..
I'm using Drand and Drop, but sometimes I use 'execute code'. Now I have three problems:
1. My player only shoots to the right.
2. The zombies won't follow the player/character (error message).
3. The camera won't follow the player/character.
Problem 1
I have a player object/sprite. It faces to the right, but of course when the player walks to the left it can't face to the right. I also made three other sprites/objects: The back of the player, the front of the player and the player walking to the left. Now I have that when one of the arrow buttons is clicked, the sprite changes to the sprite which faces that direction. This works fine. When you press the space bar, the player is supposed to fire a bullet to the direction it's facing, however, now matter which side it's facing, it shoots to the right.
This is the code I have for shooting the bullet:
(keypress - space)
Problem 2
The code I have for the zombies is:
(create)
But everytime I try to run the game, I get this error message:
I don't know why I get this and how to fix it.
Problem 3
The camera won't follow the player.
I feel like I've tried everything, which I obviously haven't because else it would've worked.
What I didn't try was code, because I really don't know how to use it and I don't just want to just copy code off of the internet. Does somebody know how to code this and explain it to me? Or does anybody know a way for the camera to follow the player in DnD which works a 100% ? I viewed other threads about this, but it doesn't seem to work for me.
Thank you for reading this, I hope you have a nice day!
I'm terribly sorry that these questions are probably really dumb!
I am making a 2d zombie shooting game as a project for school, but I'm not very good with GameMaker studio 2, in fact, I'm a complete noob..
I'm using Drand and Drop, but sometimes I use 'execute code'. Now I have three problems:
1. My player only shoots to the right.
2. The zombies won't follow the player/character (error message).
3. The camera won't follow the player/character.
Problem 1
I have a player object/sprite. It faces to the right, but of course when the player walks to the left it can't face to the right. I also made three other sprites/objects: The back of the player, the front of the player and the player walking to the left. Now I have that when one of the arrow buttons is clicked, the sprite changes to the sprite which faces that direction. This works fine. When you press the space bar, the player is supposed to fire a bullet to the direction it's facing, however, now matter which side it's facing, it shoots to the right.
This is the code I have for shooting the bullet:
(keypress - space)
Code:
bullet = instance_create_depth(x,y,0,obj_bullet) ;
bullet.speed = 10;
direction = obj_player_wright.direction;
image_angle = direction;
The code I have for the zombies is:
(create)
Code:
move_towards_point( player.x, y, speed = 5)
if( abs(angle_difference(180, direction)) < 90){
image_xscale = -1;
}else{
image_xscale = 1;
}
Code:
############################################################################################
FATAL ERROR in
action number 1
of Create Event
for object obj_zombie:
Variable obj_zombie.player(100002, -2147483648) not set before reading it.
at gml_Object_obj_zombie_Create_0 (line 5) - move_towards_point( player.x, y, speed = 5)
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_obj_zombie_Create_0 (line 5)
Problem 3
The camera won't follow the player.
I feel like I've tried everything, which I obviously haven't because else it would've worked.
What I didn't try was code, because I really don't know how to use it and I don't just want to just copy code off of the internet. Does somebody know how to code this and explain it to me? Or does anybody know a way for the camera to follow the player in DnD which works a 100% ? I viewed other threads about this, but it doesn't seem to work for me.
Thank you for reading this, I hope you have a nice day!