How to Make Enemy Follow Player?

EricTippettEricTippett Member Posts: 45
edited July 2012 in Working with GS (Mac)
Hey Everyone,

I have seen other posts on this but nothing is working so I am not sure what I am doing wrong.

So I have made a Player1 X Position (Integer) Attribute and a Player1 Y Position (Integer) Attribute

Then in the Player 1 Actor, I made a group called Get Players Position
and in that group I have a Constrain Attribute rule that says Constrain Attribute:Self.Position.X To:Game.Player1 X Position
I have another Constrain Attribute rule that says Constrain Attribute:Self.Position.Y To:Game.Player1 Y Position


I made 2 display text actors and dragged them on the screen to see if the game even recognizes the players x and y. They say Text:game.Player 1 X Position and the other actor says Text:game.Player 1 Y Position. These stay at 0 while I play, so I dont think the game even recognizes the player position. So that is the step I think is wrong.

The next step is I made an enemy. He has a Move To with the Position x: game.Player1 X Position and the Position y:game.Player Y Position.


That is all I had so far, what am I doing wrong?

I just wanted the enemies to follow the player until they get in a certain range and then move around, but stay near the player and shoot at the player in a straight line so the player can dodge, some bullets would be homing but most of them would just shoot straight. This is a game like Geometry Wars.

Best Answer

  • simo103simo103 Posts: 1,331
    Accepted Answer
    @EricTippett .... I would make new attributes for X and Y and make them Real. And you have the constrains backwards I believe. It should be constrain Game.Player1.Xposition to self.positionx etc .. try that first and see if that works.

Answers

  • EricTippettEricTippett Member Posts: 45
    edited July 2012
    Ok I deleted my integers and made them real.
    Then I made the constrains on the Player 1 Actor game.player 1 x Pos to self.position.x and same for the y
    Then I relinked it in the display text to say game.player1 x pos and one for y as well.
    The text still stays at 0 so I dont think it is reading the position still.

    I started with the official cross platform template, if that matters at all. I just made the area bigger and I put the player in the middle of the area, while the controls are still in the corner.

    I also just noticed that all the enemies are moving to the 0,0 position. So I think they work, its just that the game isnt recognizing where the player 1 ship is because the position never updates.
  • EricTippettEricTippett Member Posts: 45
    Hey I just figured out what was going on.. for some reason the actors on the scene werent updated, so I clicked on all of them and had to Revert to Prototype. Im not sure what that is though
Sign In or Register to comment.