baardbi
Well-known member
This is a modified version of a script @SciNEStist posted on Discord.
To make a monster always move towards the player in the platform modules you can make a new monster action. This will make sure that the monster always moves and faces towards the player.
1. Make a new file called MoveTowardsPlayer.asm
2. Put this code in the file and save it (I recommend putting this file in a AI folder):
3. Assign this to a free Action Step in Script Settings. In this example I assign it to AI_Behavior5:
4. Rename the label for the Action to MoveTowardsPlayer. To do this go to Project Labels (in Project Settings) and rename AI_Behavior05.
5. On the Action tab of your monster use this action for whatever action step you want. In this example I will use this on a monster with only one action step. That makes sure that the monster ALWAYS moves towards the player. If you have several action steps this step will only make the monster walk in the players direction when it reaches this action step. So even if you only have one action step you still need to make it repeat this action step (GoToFirst in this example).
That's it. Your monster will now always move in the direction of the player.
To make a monster always move towards the player in the platform modules you can make a new monster action. This will make sure that the monster always moves and faces towards the player.
1. Make a new file called MoveTowardsPlayer.asm
2. Put this code in the file and save it (I recommend putting this file in a AI folder):
;; Move towards player
TXA
STA temp
LDY player1_object
LDA Object_x_hi,y
CMP Object_x_hi,x
BCC +moveLeft
LDA #RIGHT
STA temp1
LDA #FACE_RIGHT
STA temp2
JMP +done
+moveLeft
LDA #LEFT
STA temp1
LDA #FACE_LEFT
STA temp2
+done
StartMoving temp, temp1
TXA
STA temp
ChangeFacingDirection temp, temp2
3. Assign this to a free Action Step in Script Settings. In this example I assign it to AI_Behavior5:
4. Rename the label for the Action to MoveTowardsPlayer. To do this go to Project Labels (in Project Settings) and rename AI_Behavior05.
5. On the Action tab of your monster use this action for whatever action step you want. In this example I will use this on a monster with only one action step. That makes sure that the monster ALWAYS moves towards the player. If you have several action steps this step will only make the monster walk in the players direction when it reaches this action step. So even if you only have one action step you still need to make it repeat this action step (GoToFirst in this example).
That's it. Your monster will now always move in the direction of the player.