player flip horizontal based on the characters position

digitalzerodigitalzero Member, BASIC Posts: 639

i need to find out how to always make my enemy actors face the player... its for a side scroller shooting game the hero actor controls the camera

Comments

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881

    Track the hero's xPosition in a game level attribute: heroX

    Use the following rule in the enemy Actor:

    When self.Position.X > game.heroX
          Change Attribute: self.Graphics.Flip Horizontally To: true
    otherwise
          Change Attribute: self.Graphics.Flip Horizontally To: false
    
  • digitalzerodigitalzero Member, BASIC Posts: 639

    @rthurman you always manage to save the day for me lol thanks so much! this code worked perfectly

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881

    You are welcome! Glad it will work for you.

  • digitalzerodigitalzero Member, BASIC Posts: 639

    @rthurman soooooo now im trying to track the distance between two actors... i know it has something to do with magnitude but i cant seem to find the tutorial and the one tshirt booth put up is private now

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881

    @digitalzero -- Distance would be: game.heroX-self.Position.X

  • digitalzerodigitalzero Member, BASIC Posts: 639

    okay @rthurman but check this out... lets say i have an enemy actor that shoots bullets but i want it to be about an inch away from each other and then spawn the actual bullet

  • digitalzerodigitalzero Member, BASIC Posts: 639

    Image and video hosting by TinyPic

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    edited September 2014

    Something like this:

    When abs(self.Position.X - game.heroX) < 100
          Change Attribute: self.Shoot To: true
    otherwise
          Change Attribute: self.Shoot To: false
    
  • jamie_cjamie_c ImagineLabs.rocks Member, PRO Posts: 5,772

    There is a tutorial here if you care to check it out:

Sign In or Register to comment.