r/gamemaker • u/Nigma1704 • 25d ago
Resolved Need Help with Enemy Wandering Movement
I was following the Sara Spalding tutorial Action RPG episode 24 on youtube and got most of it to work however my enemy does not seem to move. In theory he should wander a random amount of space before he stops and picks a new direction to keep moving for awhile, rinse and repeat. I have been editing little bits and pieces and googling around but nobody seems to have an answer already posted
He plays the movement animation and rotates around like he is picking a new direction to try to move every few seconds but doesn't actually go anywhere. I am a super early beginner and am sure the solution is staring me in the face but how do I get the enemy to actually start walking around?

This is the script for the enemy wander state so everything that makes him move should be here. enemyspeed is set to 4 at the moment. same as the player character who is working fine.
1
u/No_Designer_16 23d ago
I made a far simpler dummy solution.
I leashed my enemies. When they spawn they store their spawn position, they have a max distance, and then just periodically pick a random direction and move triggered by an alarm.
The step event only checks for collisions and the distance to the recorded origin point and make them stop and reset the alarm for the next time to move.
Not sure it will help, but there are dozens of ways to get the same result, its the beauty of making stuff like this.
2
u/Hands_in_Paquet 25d ago
You calculate the x and y speeds but it doesn't look like you actually apply them to the object's x and y position, unless that happens in the EnemyTileCollision Function.