G
GiovanniT
Guest
Hello, I have been trying my hand at building a small beat'em up style game much like Double Dragons for the NES. I am currently having trouble with the enemy movement.
I have the code currently set up as follows
//check left or right
if o_player1.x > self.x and
//checking if within radius to follow
distance_to_object(o_player1)<=150
and
//check radius, too close to stop
distance_to_object(o_player1)>=6 {
move_towards_point(o_player1.x+23,o_player1.y,4)
}
else
speed =0
The problem I am encountering is the enemy will move towards the player, but it wont move to the exact position. If I move the player up or down, the enemy will try to move back but then fall just short sitting right above or right under the player while trying to execute the attack. I added a screenshot, though I dont know how much that will help.
As the first one did not work I then tried removing the close distance check
if o_player1.x < self.x
and distance_to_object(o_player1)<=150{
//move towards the player at set speed
move_towards_point(o_player1.x+23,o_player1.y,4)
} else speed=0
with this one the enemy did move to the exact point as I needed it to but once it reached that point it started shaking back and forth like it was stuck, while still executing the attacks, bypassing the 0 speed check?
I also tried creating a
can attack check
Create:
can_move=false
can_attack=false
Step Event:
If distance_to_object(o_player1) <=150 and distance_to_object(o_player1) >=6{
can_move=true
}
else
if distance_to_object(o_player1) <=5{
can_attack=true
can_move=false
}
if can_move=true{
move_towards_point(o_player1.x+23,o_player1.y,4)
} else speed=0
This bit of coding did not work for me either, it appeared to be a mixture of problems from the first and second.
I have the code currently set up as follows
//check left or right
if o_player1.x > self.x and
//checking if within radius to follow
distance_to_object(o_player1)<=150
and
//check radius, too close to stop
distance_to_object(o_player1)>=6 {
move_towards_point(o_player1.x+23,o_player1.y,4)
}
else
speed =0
The problem I am encountering is the enemy will move towards the player, but it wont move to the exact position. If I move the player up or down, the enemy will try to move back but then fall just short sitting right above or right under the player while trying to execute the attack. I added a screenshot, though I dont know how much that will help.
As the first one did not work I then tried removing the close distance check
if o_player1.x < self.x
and distance_to_object(o_player1)<=150{
//move towards the player at set speed
move_towards_point(o_player1.x+23,o_player1.y,4)
} else speed=0
with this one the enemy did move to the exact point as I needed it to but once it reached that point it started shaking back and forth like it was stuck, while still executing the attacks, bypassing the 0 speed check?
I also tried creating a
can attack check
Create:
can_move=false
can_attack=false
Step Event:
If distance_to_object(o_player1) <=150 and distance_to_object(o_player1) >=6{
can_move=true
}
else
if distance_to_object(o_player1) <=5{
can_attack=true
can_move=false
}
if can_move=true{
move_towards_point(o_player1.x+23,o_player1.y,4)
} else speed=0
This bit of coding did not work for me either, it appeared to be a mixture of problems from the first and second.
Attachments
-
52.7 KB Views: 11