I want this guard moving, so that be always stay opossite player.
It means: When player move one step left left, guard move left one step too. When player go up guard move stay in current position.
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fobrazku.cz%2Fobr738370_game.png&hash=1ad7da06c0e1023959151a88e35868c3c4f408c0)
Look into a caterpillar script like Zeriab's Caterpillar Script (http://rmrk.net/index.php?topic=29225.0). Could probably be done with events, but it would be a lot more tedious.
EDIT: Nvm, I misunderstood the question. Sorry.
I don't think that's what he wants (and besides, I need to fix that script).
I think he means he wants the guard to always prevent the player from going past that line. He doesn't want the guard to follow him; he just wants the guard to always be on the same X-coordinate as the player.
@michael95 - One way to event this would be to run a parallel process event in the map which looks something like this:
Loop
Control Variables [X Difference] = Player's Map X
Control Variables [X Difference] -= [Guard]'s Map X
Conditional Branch: Variable [X Difference] > 0
Move Event: Guard -> Move Right
Wait: 6 frames
Else
Conditional Branch: Variable [X Difference] < 0
Move Event: Guard -> Move Left
Wait: 6 frames
Else
Break Loop
Branch End
Branch End
Move Event: Guard -> Turn Down
Wait: 6 frames
That would be the basic idea anyway - I don't know how many each of the wait frames would have to be.
And of course, the guard will have to be at least as fast as the player for this to work.
EDIT::
I've attached a picture of the event as that will probably be of more assistance:
(https://rmrk.net/index.php?action=dlattach;topic=43269.0;attach=23908;image)
I have one problem: the guard moves automaticaly down and when is down opossite of player guard starts moving so, I want.
Err, I don't know what you just said. I tested that out in a game, and the guard never ever moved down - it worked just as you wanted it to work. Make sure that the last move event is Turn Down, as in the screenshot, not Move Down.
I fixed it. I had in autonomous movement move route command move toward player.